Creates and starts an animated GUI for positioning the vertices of a graph in 2 dimensions.
rViewGraph(object, names, layout, directed, running, ...)# S3 method for default
rViewGraph(
object,
names = seq(max(object)),
layout = NULL,
directed = FALSE,
running = TRUE,
...
)
# S3 method for Matrix
rViewGraph(
object,
names = 1:max(dim(object)),
layout = NULL,
directed = FALSE,
running = TRUE,
...
)
# S3 method for igraph
rViewGraph(
object,
names = igraph::V(object)$name,
layout = igraph::layout.random(object),
directed = igraph::is.directed(object),
running = TRUE,
...
)
the object specifying the graph
the names of the nodes
the starting positions of the vertices
indicates whether or not the graph is directed
indicates whether or not to start with animation running
passed along extra arguments.
rViewGraph
is intended only for interactive use. When used in a non-interactive envirionment
it immediately exists returning the value NULL
.
Otherwise, all versions of rViewGraph
return a list of functions that control the actions of
the interactive viewer. None of the functions in the list take an argument.
Starts the GUI running if it's not already doing so.
Stops the GUI running if it's running.
Stops the GUI and hides it.
Shows the GUI. If it was running when hide
was called, it starts running again.
Returns the coordinates of the vertices that are currently shown in the GUI. These are in the format that igraph
expects for layouts.
Creates and starts a 'Java' GUI showing a real time animation of a Newton-Raphson optimization of a force function specified between the vertices of an arbitrary graph. There are attractive forces between adjacent vertices and repulsive forces between all vertices. The repulsions go smoothly to zero for a finite distance between vertices so that, unlike some other methods, different components don't send each other off to infinity.
This is a generic function that delegates its work to specific functions depending on
the class of the first argument. It can handle an incidence matrix, a list of
edges, and an igraph
graph object.
The program is controlled by a slide bar, some buttons, the arrow, home and shift keys, but mostly by mouse operations. All three mouse buttons are used.
The slide bar at the bottom controls the repulsive force in the energy equation used to set the coordinates.
Mouse operations without shift key and without control key pressed.
Left mouse: Drags a vertex. Vertex is free on release.
Middle mouse: Drags a vertex. Vertex is fixed at release position.
Right mouse: Translates the view by the amount dragged. A bit like putting your finger on a piece of paper and moving it.
Double click with any mouse button in the background: Resets the vertices to new random positions.
Mouse operations with shift key but without control key pressed.
Left mouse: Drags a vertex and the component it is in. Vertex and component free on release.
Middle mouse: Drags a vertex and the component it is in. Vertex and component are fixed at release positions.
Right mouse: Translates the positions of the vertices relative to the position of the canvas by the amount dragged. This is useful to center the picture on the canvas ready for outputting.
Mouse operations without shift key but with control key pressed.
Left mouse: Click on a vertex to un-delete any deleted neighbours.
Middle mouse: Click on a vertex to delete it from the graph.
Double click left mouse: Replaces all deleted vertices in the graph.
Double click middle mouse: Deletes all vertices from the graph.
Mouse operations with shift key and with control key pressed.
Left mouse: Click on a vertex to replace all vertices in the same component to the graph.
Middle mouse: Click on a vertex to delete it and the component it is in from the graph.
Key functions without shift key pressed. Mouse has to be in the picture canvas.
Up arrow: Increases the scale of viewing by 10%.
Down arrow: Decreases the scale of viewing by 10%.
Left arrow: Rotates the view by 15 degrees clockwise.
Right arrow: Rotates the view by 15 degrees anticlockwise.
Home key: Undoes all scalings and rotations and places the origin at the center of the picture canvas.
Key functions with shift key pressed. Mouse has to be in the picture canvas.
Up arrow: Increases the vertex positions by 10% relative to the scale of the canvas.
Down arrow: Decreases the vertex positions by 10% relative to the scale of the canvas.
Left arrow: Rotates the vertex positions by 15 degrees clockwise relative to the canvas orientation.
Right arrow: Rotates the vertex positions by 15 degrees anticlockwise relative to the canvas orientation.
# NOT RUN {
# Viewing an Erdos Renyi random graph specified by random edges.
f = sample(100,size=200,replace=TRUE)
t = sample(100,size=200,replace=TRUE)
vft = rViewGraph(cbind(f,t))
#
# Edges can also be specified in \code{igraph} style.
e = c(t,f)
ve = rViewGraph(e)
# }
Run the code above in your browser using DataLab