drawGraph                package:ggm                R Documentation

_D_r_a_w_i_n_g _a _g_r_a_p_h _w_i_t_h _a _s_i_m_p_l_e _p_o_i_n_t _a_n_d _c_l_i_c_k _i_n_t_e_r_f_a_c_e.

_D_e_s_c_r_i_p_t_i_o_n:

     Draw a graph from its adjacency matrix representation.

_U_s_a_g_e:

     drawGraph(amat, coor = NULL, adjust = TRUE, alpha = 1.5,
                     beta = 3, lwd = 1, ecol = "blue", left = FALSE)

_A_r_g_u_m_e_n_t_s:

    amat: the adjacency matrix representation of the graph. This can be
          an undirected graph a directed acyclic graph or an ancestral
          graph.

    coor: an optional matrix of dimensions p times 2 where p is the
          number of vertices of the graph. If 'coor=NULL' then the
          function chooses a default position for the nodes.

  adjust: a logical value. If 'TRUE' the graph is plotted and the
          system waits until the mouse button is pressed (same
          behaviour of 'locator' function.

   alpha: a positive value between controlling the distance from the
          end of the edges to the nodes of the graph.

    beta: a positive value controlling the distance of the labels of
          the variables from the nodes.

     lwd: line width of the edges (default: 1).

    ecol: color of the edges (default: "blue").

    left: a logical value. If 'TRUE' the default location of the
          vertices of DAGs in topological order is from right to left.

_D_e_t_a_i_l_s:

     The function is a very simple tool useful for displaying small
     graphs, with a rudimentary interface for moving nodes and edges of
     a given graph and  adjusting the final plot. For better displays
     use 'dynamicGraph' or 'Rgraphviz' package in Bioconductor project.

_V_a_l_u_e:

     The function plots the graph with a initial positioning of the
     nodes, as  specified by  'coor' and remains in a waiting state.
     The position of each node can be shifted by pointing and clicking
     (with the first mouse button) close to the node. When the mouse
     button is pressed the node which is closer to the selected point
     is moved to that position. Thus, one must be careful to click
     closer to the selected node than to any other node.  The nodes can
     be moved to any position by repeating the previous operation. The
     adjustment process is terminated by pressing any mouse button
     other than the first.

     At the end of the process, the function returns invisibly the
     coordinates of the nodes. The coordinates may be used later to
     redisplay the graph.

_A_u_t_h_o_r(_s):

     Giovanni M. Marchetti

_R_e_f_e_r_e_n_c_e_s:

     'dynamicGraph', 'Rgraphwiz', <URL: http://www.bioconductor.org>.

     GraphViz, Graph Visualization Project. AT&T Research. <URL:
     http://www.graphviz.org>.

_S_e_e _A_l_s_o:

     'UG', 'DAG', 'makeAG'

_E_x_a_m_p_l_e_s:

     ## A directed acyclic graph
     d <- DAG(y1 ~ y2+y6, y2 ~ y3, y3 ~ y5+y6, y4 ~ y5+y6)
     ## Not run: drawGraph(d)

     ## An undirected graph
     g <- UG(~giova*anto*armo + anto*arj*sara) 
     ## Not run: drawGraph(d)

     ## An ancestral graph
     ag <- makeAG(ug=UG(~y0*y1), dag=DAG(y4~y2, y2~y1), bg=UG(~y2*y3+y3*y4))
     ## Not run: drawGraph(ag)
     ## Not run: drawGraph(ag, bid=FALSE)

     ## A more complex example with coordinates: the UNIX evolution
     xy <-
     structure(c(5, 15, 23, 25, 26, 17, 8, 6, 6, 7, 39, 33, 23, 49, 
     19, 34, 13, 29, 50, 68, 70, 86, 89, 64, 81, 45, 64, 49, 64, 87, 
     65, 65, 44, 37, 64, 68, 73, 85, 83, 95, 84, 0, 7, 15, 27, 44, 
     37, 36, 20, 51, 65, 44, 64, 59, 73, 69, 78, 81, 90, 97, 89, 72, 
     85, 74, 62, 68, 59, 52, 48, 43, 50, 34, 21, 18, 5, 1, 10, 2, 
     11, 2, 1, 44), .Dim = c(41, 2), .Dimnames = list(NULL, c("x", 
     "y")))
     Unix <- DAG(
                     SystemV.3 ~ SystemV.2,
                     SystemV.2 ~ SystemV.0,
                     SystemV.0 ~ TS4.0,
                     TS4.0 ~ Unix.TS3.0 + Unix.TS.PP + CB.Unix.3,
                     PDP11.SysV ~ CB.Unix.3,
                     CB.Unix.3 ~ CB.Unix.2,
                     CB.Unix.2 ~ CB.Unix.1,
                     Unix.TS.PP ~ CB.Unix.3,
                     Unix.TS3.0 ~ Unix.TS1.0 + PWB2.0 + USG3.0 + Interdata,
                     USG3.0 ~ USG2.0,
                     PWB2.0 ~ Interdata + PWB1.2,
                     USG2.0 ~ USG1.0,
                     CB.Unix.1 ~ USG1.0,
                     PWB1.2 ~ PWB1.0,
                     USG1.0 ~ PWB1.0,
                     PWB1.0 ~ FifthEd,
                     SixthEd ~ FifthEd,
                     LSX ~ SixthEd,
                     MiniUnix ~ SixthEd,
                     Interdata ~ SixthEd,
                     Wollongong ~ SixthEd,
                     SeventhEd ~ Interdata,
                     BSD1 ~ SixthEd,
                     Xenix ~ SeventhEd,
                     V32 ~ SeventhEd,
                     Uniplus ~ SeventhEd,
                     BSD3 ~ V32,
                     BSD2 ~ BSD1,
                     BSD4 ~ BSD3,
                     BSD4.1 ~ BSD4,
                     EigthEd ~ SeventhEd + BSD4.1,
                     NinethEd ~ EigthEd,
                     Ultrix32 ~ BSD4.2,
                     BSD4.2 ~ BSD4.1,
                     BSD4.3 ~ BSD4.2,
                     BSD2.8 ~ BSD4.1 + BSD2,
                     BSD2.9 ~ BSD2.8,
                     Ultrix11 ~ BSD2.8 + V7M + SeventhEd,
                     V7M ~ SeventhEd
                     )
     drawGraph(Unix, coor=xy, adjust=FALSE)
     # dev.print(file="unix.fig", device=xfig) # Edit the graph with Xfig

