plotG {gRapHD}R Documentation

Plot a graph

Description

Plots a graph using the Fruchterman-Reingold algorithm.

Usage

plotG(model=NULL,edges=NULL,v=NULL,numIter=50,main=NULL,tcex=1,
                  plotVert=TRUE,labelVert=TRUE,energy=FALSE,
                  useWeights=FALSE,hlv=NULL,hlc="red",vs=0.01,
                  pos=NULL,edcol="darkgray",edlty=1,edlwd=1,vlcol=0,
                  sb=1,lcex=.40,vlabs=NULL,asp=NA,disp=TRUE,font=1)

Arguments

model a gRapHD object.
edges matrix with 2 columns, each row representing one edge, and each column one of the vertices in the edge.
v list of vertices to be plotted. If NULL, all vertices will be plotted
numIter number of iterations for the Fruchterman-Reingold algorithm.
main main title.
tcex numeric character expansion factor for the main title; multiplied by par yields the final character size. NULL and NA are equivalent to 1.0.
plotVert if TRUE the vertices are plotted.
labelVert if TRUE the vertices are labelled.
energy if TRUE use the minimum energy as initial values.
useWeights if TRUE use the model$statSeq as edge length weights).
hlv list of vertices to be highlighted.
hlc colour to be used in the highlighted vertices.
vs radii of the edges (scalar or vector with length equal to the number of vertices). See 'Details'.
pos initial coordinate values for the vertices.
edcol colour of the edges.
edlty type of line for the edges.
edlwd width of the line for the edges.
vlcol colour of the vertices borders.
sb symbol to be used in the vertices (length 1 or number of vertices): 0 is a ellipse (a=2*vs,b=vs), 1 a circle, 2 a square, 3 or higher represents the number of sides.
lcex numeric character expansion factor for the labels; multiplied by par yields the final character size. NULL and NA are equivalent to 1.0.
vlabs labels to be used in the vertices. If NULL, the vertices numbers are used.
asp numeric, giving the aspect ratio y/x (see plot.window for more details).
disp if TRUE (default), the graph is plotted.
font an integer which specifies which font to use for the labels. If possible, device drivers let 1 correspond to plain text (the default), 2 to bold face, 3 to italic and 4 to bold italic.

Details

Plot a graph based on the list of edges.
Only one (model or edges) should be provided. If model, the function uses also the information about the type of variables (discrete or continuous). If edges, then all variables are plotted as continuous (circles).
The plotting area is square, ranging from 0 to 1. The unit of parameter vs follow the axes.
The algorithm proposed by Fruchterman & Reingold (1991) is used to determine the position of each vertex. It is not initialised randomly, but in a regular grid.

Value

If ret is TRUE, the coordinates for the vertices are returned.

Author(s)

Gabriel Coelho Goncalves de Abreu (Gabriel.Abreu@agrsci.dk)
Rodrigo Labouriau (Rodrigo.Labouriau@agrsci.dk)
David Edwards (David.Edwards@agrsci.dk)

References

Fruchterman, T.M.J. and Reingold, E.M. (1991) Graph Drawing by Force-directed Placement. SOFTWARE-PRACTICE AND EXPERIENCE, VOL. 21(11), 1129-1164.
Csardi G, Nepusz T: The igraph software package for complex network research, InterJournal, Complex Systems 1695. 2006. http://igraph.sf.net

Examples

  data(dsCont)
  m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR")
  plotG(model=m1,numIter=1000)
  
  # or
  plotG(edges=m1$edges,numIter=1000)

  # or
  plotG(edges=m1$edges,v=c(13,28,32,10,16,26,31,22),numIter=1000)

  # or
  plotG(edges=m1$edges,v=1:40,numIter=1000)
  
  # or
  plotG(model=m1,numIter=1000,plotVert=FALSE,labelVert=FALSE)
  
  #############
  r <- 3
  edges <- rep(1,r)
  x <- 2+r-1
  edges <- c(edges,sort(rep(2:x,r-1)))
  edges <- c(edges,sort(rep((x+1):(x+(x-1)*(r-1)),r-2)))
  edges <- c(edges,sort(rep((x+(x-1)*(r-1)+1):(x+(x-1)*(r-1)+(x-1)*(r-1)*(r-2)),r-3)))
  edges <- cbind(edges,2:(length(edges)+1))
  a <- neighbourhood(edges=edges,orig=1,rad=r)
  vs <- a$v[,2]
  vs <- 1/vs
  vs[1] <- 2
  vs <- vs/30
  plotG(edges=edges,numIter=200,hlv=a$v[,1],hlc=colours()[386:383][a$v[,2]+1],vs=vs)


[Package gRapHD version 0.1.0 Index]