dynamicGraphMain: Dynamic Graph

Description Usage Arguments Details Value All object in the graph window: Vertices (vertices and factor vertices): Edges (edges to/from vertices, blocks and factors): Blocks, opened: Blocks, closed: Factor vertices: Factor edges: The panel for vertices: The panel for blocks in tree and vertices: The graph: Rotation: Acknowledgments Note Author(s) References See Also Examples

Description

Interactive plot for manipulating graphs.

Usage

1
2
3

Arguments

vertexList

List of vertices (each of class containing the class dg.Vertex) created by returnVertexList or exported from dynamicGraphMain.

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 computing the test statistic when an edge is labeled. The returned object from testEdge should have the methods label and width for extracting the label of a test for putting the label on the edge and for extracting the width for the edge. See dg.Model-class.

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.

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.

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:

Vertices (vertices and factor vertices):

Right click the vertex to get the pop up menu of the vertex:

The main menu "Variables":

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

Right click the edge to get the pop up menu of the edge:

The main menu "Edges":

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:

Blocks, closed:

Right click the block to get the pop up menu of the closed block:

The main menu "Blocks":

Factor vertices:

Right click the factor vertex to get the pop up menu of the factor: Actions as for vertices. The main menu "Generators":

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:

The panel for blocks in tree and vertices:

The graph:

Rotation:

Acknowledgments

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

Note

Vertices, edges, blocks, block edges, factors, and factor edges are objects of the following classes: dg.Vertex, dg.Edge, and dg.Block contains dg.Node, dg.FactorVertex contains dg.Vertex, and dg.VertexEdge, dg.BlockEdge, dg.FactorEdge contains dg.Edge.

The methods draw, color, color<-, label, label<-, labelPosition, labelPosition<-, name, name<-, index, index<-, position, position<-, stratum, stratum<-, visible, visible<-, addToPopups, oriented, oriented<-, width, width<-, nodeIndicesOfEdge, nodeIndicesOfEdge<-, nodeTypesOfEdge, ancestors, ancestors<-, descendants, and descendants<-, are implemented for objects of these classes.

For lists of vertices, edges, blocks, block edges, factors, and factor edges the methods Names, Names<-, Colors, Colors<-, Labels, Labels<-, LabelPositions, LabelPositions<-, Positions, Positions<-, Strata, Strata<-, Indices, NodeAncestors, NodeAncestors<-, NodeDescendants, and NodeDescendants<- are available.

The model object of the call of dynamicGraphMain should have the methods modifyModel, testEdge, graphEdges, and setGraphEdges. When the graph is modified, by adding or dropping vertices or edge, the method modifyModel is called on the argument object of dynamicGraphMain. If an object is returned in the list of the returned value from modifyModel then object in dynamicGraphMain is replaced by this object, and the object is also assigned in the top level environment, if objectName was given to dynamicGraphMain.

The method testEdge of object should return an object with the methods label and width for labeling edges, see dg.Test-class.

The methods graphEdges and setGraphEdges are used to communicate the graph components between several views of the same model. The method graphEdges of the model object is for returning an object of class dg.graphedges-class to draw in the view, depending on the viewType. The method setGraphEdges of the model object is called on the model object when the model is modified.

Author(s)

Jens Henrik Badsberg

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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))

dynamicGraph documentation built on May 29, 2017, 8:01 p.m.