dynamicGraph (version 0.2.2.6)

dynamicGraphMain: Dynamic Graph

Description

Interactive plot for manipulating graphs.

Usage

dynamicGraphMain(vertexList = NULL, blockList = NULL, 
                 dg = NULL, object = NULL, objectName = NULL, 
                 control = dg.control(...), ...)

Arguments

vertexList
List of vertices (each of class containing the class dg.Vertex) created by returnVertexList or exported from dyna
blockList
List of blocks (each of class dg.Block) created by setBlocks or exported from dynamicGraphMain.
dg
dg is an object of class dg.graphedges-class.
object
NULL, or object with the methods modifyModel and testEdge - for respectively updating the object when the graph is updated, and for comp
objectName
If set to a text string then the object is assigned with this name in .Global.Env when the object is updated.
control
Options for dynamicGraphMain, see dg.control.
...
Additional arguments.

Value

  • An object of class DynamicGraph-class (if not returnNull is TRUE) with the lists of vertices and blocks (block trees) of the dynamicGraph, and list of models, each (of class DynamicGraphModel-class) with the views of the model.

    Each view (of class DynamicGraphView-class) of a model will hold the edges (edges between vertices, factors and blocks) and factor- and extra-vertices of the view, together with which vertices and blocks are visible in the view.

All object in the graph window:

  • Left click, hold and drag:
{The object will move.} Left click:{Action to the object: Vertices, edges, and blocks will highlight, at vertices and blocks edges are added after highlighting, tests are computed for edge labels.} Left or right click, with SHIFT or/and CONTROL:{The object will be marked.} Double left click:{Action to object: Vertices and edges are deleted, blocks will close, closed blocks will open.} Right click:{The pop up menu of the object will appear.}

Vertices (vertices and factor vertices):

Right click the vertex to get the pop up menu of the vertex:
  • Highlight a vertex:
{For adding an edge - Left click the vertex.} Highlight a vertex:{For adding to "selectedNodes" - Left or right click the vertex while holding SHIFT or/and CONTROL down.} Mark a vertex:{For adding edges, etc. - Left or right click the vertex while holding SHIFT or/and CONTROL down.} Cancel highlighting:{Left click (or drag) the vertex.} Add an edge:{After first highlighting a vertex - Left click the other vertex.} Move a vertex:{Left click and drag the vertex.} Move a vertex label:{Left click and drag the label of the vertex.} Delete a vertex:{Double left click the vertex.} Create new graph:{A slave window with the vertex delete - Select "Drop vertex" from pop up menu at the vertex.} Change a vertex label:{Double left click the label, and enter the new label in the appearing dialog window.} Delete a vertex label:{Select "Delete vertex label" from the pop up menu at the vertex or at the vertex label.} Create new vertex:{At mouse position - Middle click the canvas.} Create new vertex:{At mouse position with the edge to last vertex - Double middle click the canvas.}

itemize

  • Export the block list:

code

object

item

  • Display, add, a vertex:
  • Display, add, a vertex:
  • Export the vertex list:
  • Export the labels:
  • Export the edge list:
  • Export the block edges:

Edges (edges to/from vertices, blocks and factors):

Right click the edge to get the pop up menu of the edge:
  • Highlight a edge:
{Left click the edge.} Highlight a edge:{For adding to "selectedEdges" - Left or right click the edge while holding SHIFT or/and CONTROL down.} Add an edge:{Left click first the vertex (or block) to highlight, and then left click other vertex (or block).} Delete an edge:{And update in the current window - Double left click the edge.} Delete an edge:{And create a slave graph with the resulting graph - Select "Drop edge" from the pop up menu at the edge.} Move an edge (2 vertices):{Left click the edge and drag the edge.} Move an edge label:{Left click the edge label and drag the label.} Set an edge label:{Select "Set edge label" from the edge pop up menu.} Compute an edge label:{Left click the edge label, or select "Compute edge label" from pop up menu at the edge.} Compute an edge label:{Force computation for "harder models" - Double left click the edge label, or select "Force compute edge label" from pop up menu of the edge.} Delete an edge label:{Triple left click the edge label, or select "Delete label of edge" from the pop up menu at the edge.}

Blocks, opened:

Right click the block label (or colored block canvas if drawBlockBackground is set to TRUE) to get the pop up menu of opened block:
  • Move a block:
{With its sub blocks and vertices - Left click the block label or colored block canvas and drag the block. [ Slow !!!] } Resize a block:{Left click a block corner or a block edge and drag. } Minimize a block:{With its sub blocks and vertices - Double left click the block label or the colored block canvas. } Maximize a block:{Zoom to the block - Right click the block label or colored the block canvas and select "Maximize" in the appering popup menu. } Zoom out to the full graph:{Right click the block label or colored block canvas and select "Redraw (Zoom to) full graph" in the appearing block pop up menu. }

Blocks, closed:

Right click the block to get the pop up menu of the closed block:
  • Highlight a block:
{For adding edges from all vertices of the block to a vertex or a block - Left click the block.} Highlight a block:{For adding to "selectedNodes" - Left or right click the block while holding SHIFT or/and CONTROL down.} Mark a block:{For adding edges, etc. - Left or right click the block while holding SHIFT or/and CONTROL down.} Cancel highlighting:{Of a block - Left click (or drag) the block.} Add edges:{To all vertices of block after highlighting first a block or a vertex - Click the other block.} Move a closed block:{Left click and drag the block.} Move a block label:{Left click and drag the label of the block.} Open a closed block:{Double left click the block.} Change a block label:{Double left click the label of the closed block, and enter the new label in the appearing dialog window.} Delete a block label:{Select "Delete label of block" from the pop up menu at the block or the block label.}

Factor vertices:

Right click the factor vertex to get the pop up menu of the factor: Actions as for vertices. The main menu "Generators":
  • Export the factor vertices:
{Select "Assign 'factorVertexList' in .GlobalEnv". } Export the factor edges:{Select "Assign 'factorEdgeList' in .GlobalEnv". }

Factor edges:

Right click the factor edge to get the pop up menu of the factor edge: Actions are as for edges.

The panel for vertices:

  • Highlight vertex name for adding or deleting vertex:
{ Left click the vertex name. } Delete or add vertices:{ Double left click a vertex name. } Popup menu for selected vertex:{ Click "Popup selected in panel" in "File Menu". } Dialog window for properties:{ Middle click vertex name. }

The panel for blocks in tree and vertices:

    % \item{Highlight vertex name for adding or deleting vertex:}{ % Left click the vertex name. % } % \item{Delete or add vertices:}{ % Double left click a vertex name. % }
  • Move vertex to other block:
{ Left click the vertex name and drag to the other block. } Move block to other block:{ Left click the block name and drag to the other block. } Popup menu for selected vertex or block :{ Click "Popup selected in panel" in "File Menu". }

The graph:

  • Create a slave window:
{Select "Make slave window: Same model".} Create a slave window:{Select "Make slave window: Copy model".}

Switch class of view:{Select "Set class of graph window".}

Refresh:{Faster fix of "corrupted" window: Select "Refresh view (set positions as 'stored')".} Redraw the view (zoom out):{Select "Redraw graph window (more refreshing)".} Update model:{Select "Update model and redraw (total refreshing)".}

Enable rotation:{Select "Rest (enable) rotation".} Disable rotation:{Select "Disable rotation".}

Zoom in:{Select "Zoom in" from main menu, or hit in canvas. } Zoom out:{Select "Zoom out" from main menu, or hit in canvas.}

Export current arguments:{Select "Assign 'Args' in .GlobalEnv".} Export the model lattice:{Select "Assign 'frameModels' in .GlobalEnv".} Export the graph lattice:{Select "Assign 'frameViews' in .GlobalEnv".} Export the graph window:{Select "Assign 'graphWindow' in .GlobalEnv".} Export the object:{Select "Assign 'object' in .GlobalEnv".}

Rotation:

  • Enable rotation:
{Select "Enable (reset) transformation" from the main menu "Graph".} Rotate the graph:{Middle click the canvas, and drag.} Disable rotation:{Select "Disable transformation" from the main menu "Graph".} Export transformation:{Export the projection matrix - Select "Assign 'transformation' in .GlobalEnv" from the main menu "Graph".}

Acknowledgments

Many thanks to the gR-group for useful discussions, especially to Claus Dethlefsen for testing early versions of this package on DEAL.

Details

This is a dynamic plotting tool for handling graphs. The lay out of the graph can be edited by moving the vertices of the graph by the mouse, and edges can be added by clicking vertices and dropping by clicking the edges.

The function is incremental in the sense that the user can add a method for updating the model object of the window when the graph is updated, and a method for computing the test of an edge when the edge is clicked by the mouse. Edges can be oriented, drawn by arrows. Blocks can be used to define a causal structure of the variables represented by vertices, and edges between blocks are then oriented. Blocks can be given in a structure such that descendant blocks of a blocks also are closed when a block is closed. A secondary set of vertices, factor vertices, can be used to represent hypergraphs. "Slave graph windows" can be created: The windows will share vertices and blocks, thus when a vertex is moved in one window, the position of the vertex will also change in all slave windows. The edges are not shared among windows, since the individual windows will typical represent different models. Thus factors (vertices and edges) are not shared between graph windows.

References

CoCo, with a guide at http://www.jstatsoft.org/v06/i04/, has an interface to dynamicGraph.

See Also

See also DynamicGraph and all the other functions of this package.

An example has been divided on the following 4 manual pages: dg.Model-class and dg.Test-class gives an example of a model object with test object. The pages of dg.graphedges-class show how the user can add menu items with actions that redraws the graph after modification of edges. Finally, validVertexClasses show how to create a new vertex class with a new symbol for drawing the vertex and an item added to the pop up menu of the new vertex class. The demo demo(Circle.newClass) of dynamicGraph will do this example collected from these 4 pages.

Examples

Run this code
require(tcltk)
require(dynamicGraph)

V.Names <- paste(c("Sex", "Age", "Eye", "FEV", "Hair", "Shosize"),
                 1:6, sep ="/")

V.Types <- c("Discrete", "Ordinal", "Discrete",
             "Continuous", "Discrete", "Continuous")

Vertices <- returnVertexList(V.Names, types = V.Types, color = "red")

From <- c(1, 2, 3, 4, 5, 6)
To   <- c(2, 3, 4, 5, 6, 1)

EdgeList <- vector("list", length(To))
for (j in seq(along = To)) EdgeList[[j]] <- c(From[j], To[j])
Edges <- returnEdgeList(EdgeList, Vertices, color = "black")

# Z <- dynamicGraphMain(Vertices, edgeList = Edges, control = dg.control(w = 4))

graph <- new("dg.graph", vertexList = Vertices, edgeList = Edges)
W <- dg(graph, control = dg.control(w = 4))

Run the code above in your browser using DataLab