- add(i)
If the graph does not contain vertices indexed by i
,
they are added to it. i
may be any integer or integer vector.
- remove(i)
If the graph contains vertices indexed by i
,
they are disconnected from
their neighbours and removed from the graph. i
may be
any integer or integer vector.
- connect(i,j)
If the graph does not have edges between vertices
indexed by i
and j
, they are made.
If i
and j
are of different lengths, only the
first min(length(i),length(j))
values are used.
If the relevant vertices are are not already in the graph,
they are first made and added.
i
and j
may be any integers or integer vectors.
- disconnect(i,j)
If the graph has edges between vertices
indexed by i
and
j
they are removed. If i
and j
are of
different lengths, only the
first min(length(i),length(j))
values are used.
The vertices themselves are not removed, even if they have no
other neighbours. i
and j
may be any integers
or integer vectors.
- clear()
All vertices and edges are removed from the graph,
however, any customizations
made to the appearance of the vertices will persist
until clearMap()
is called.
- isDirected()
Returns TRUE
if the graph's edges are directed,
FALSE
otherwise.
- getIds()
Returns a vector of all the vertex
indices that the viewer has
encountered, whether or not they are currently in the graph.
- contains(id)
Returns a vector of booleans indicating whether the
vertices corresponding to the given indices are currently in the graph.
- connects(i,j)
Returns a vector of booleans indicating whether the
vertices with the indices in vector i
are
connected to the corresponding
vertices in j
. If i
and j
are of
different lengths, only
first min(length(i),length(j))
values are queried.
- neighbours(i)
Returns a list of vectors containing
the neighbours of the vertices indexed by i
. If the graph is
directed, both in and out neighbours are included. If a vertex is
unconnected, an empty vector is returned. If an index is for a vertex
that is not currently in the graph, NULL
is returned.
- neighbors(i)
Alias for neighbours(i)
.
- inNeighbours(i)
Returns a list of vectors containing the
indices of vertices with edges from them to the ones in i
.
If the graph is undirected, this is the same as neighbours(i)
.
- inNeighbors(i)
Alias for inNeighbours(i)
.
- outNeighbours(i)
Returns a list of vectors containing the
indices of vertices with edges to them from the ones in i
.
If the graph is undirected, this is the same as neighbours(i)
.
- outNeighbors(i)
Alias for outNeighbours(i)
.
- getVertices()
Returns a vector of the indices of
all vertices currently
in the graph.
- getEdges()
Returns a matrix with 2 columns and a row for each edge
in the current graph. Each row gives the indices of the vertices that the
edge connects. If the edges are directed,
the connections are oriented from vertices
in the first column to those in the second.
- getX(id)
Returns the current horizontal
coordinates of the vertices with
indices in id
. Returns 0 if an index has not previously been seen.
- getY(id)
Returns the current vertical coordinates of the vertices with
indices in id
. Returns 0 if an index has not previously been seen.
- setXY(id, x, y)
Sets the horizontal and vertical coordinates for the
vertices with indices in id
. If x
or y
are not as long
as id
their values are repeated cyclically to get vectors of the
right length.
- label(i,lab=i)
Sets the strings shown on the
vertices indexed by i
to those specified
by lab
. If lab
is not as long as i
,
its values are repeated cyclically to
get a vector of the right length.
An error will occur if lab
can't be interpreted as
a vector of strings.
- colour(i,col="yellow")
Sets the colours of the
vertices indexed by i
to those specified
by col
. If col
is not as long as i
,
its values are repeated cyclically to
get a vector of the right length.
Colours can be specified in the usual R
ways.
- color(i,col="yellow")
Alias for colours(i,col)
.
- shape(i,shp=0)
Sets the shapes of the vertices
indexed by i
to those specified by
shp
. If shp
is not as long as i
,
its values are repeated cyclically to
get a vector or the right length. Shapes are specified as integers:
- size(i,width=-1,height=width)
Sets the sizes of the
vertices indexed by i
to those specified by
width
and height
.
If, for a certain index, both width
and height
are
non-negative, the size of the vertex is fixed.
If either of width
or height
is negative,
the size of the vertex
is chosen adaptively to fit the current label.
If width
or height
are not as long as i
,
their values are repeated cyclically to get vectors of the right length.
- map(i,lab=i,col="yellow",shp=0,width=-1,height=width
Combines
label()
, colour()
, shape()
and size()
in a
single index-to-appearance mapping function.
These functions can be called before or
after the vertices have been added to the graph,
and the representations will persist for
vertices removed from, and replaced in, the graph until
until they are explicitly changed or clearMap()
is called.
- clearMap()
Resets all vertices to the default
appearance of yellow rectangle labeled
with the index.
- run()
Starts the GUI running if it's not already doing so.
- stop()
Stops the GUI running if it's running.
- isRunning()
Returns TRUE
if the animation is running,
FALSE
otherwise.
- show()
Shows the GUI. If it was running
when hide()
was called, it starts running again.
- hide()
Stops the GUI and hides it.
- showPaper(size = "letter", landscape = TRUE)
Indicates,
with a different colour, the portion of the
plane corresponding to a choice of paper for printing.
size
can be any of
letter
, A4
, A3
, A2
, A1
,
A0
, C1
, or C0
.
landscape
can be either TRUE
or FALSE
,
in which case portrait orientation
is used. The default is to show the portion of the plane
that would be printed on
US letter in landscape orientation.
- hidePaper()
By default the GUI indicates,
with a different colour, the portion
of the plane that corresponds to the current
choice of paper for printing. This function
removes that area.
- showAxes()
Shows the axes if they are hidden.
- hideAxes()
By default, axes are shown to indicate the origin. This
function hides them.
- ps()
Starts a Java
PostScript print job dialog box that can be
used send the current view of the graph to a printer or to write a
PostScript file. The plot
produced should closely match what is indicated by showPaper
.
- save()
Returns a list
specifying the current state of the
graph structure, vertex coordinates, and vertex appearance map.
- restore(grob)
Restores a saved graph and map state.