An directed graph with 5 nodes, 5 edges, and two labelled subgraphs.
In all cases the graph is explicitly declared with ellipse shaped nodes. The dot file edges are declared in alphabetical order as this is the (assumed) default for how Rgraphviz will pass edges internally to graphviz.
Dot file for graphviz:
|
R code for Rgraphviz and gridGraphviz: # load Rgraphviz library library(Rgraphviz) # nodes nodes <- c(letters[1:4], "f") #edges edgeList <- list(a=list(edges=c("b", "f")), b=list(edges=c("c")), c=list(edges=c("d")), d=list(), f=list(edges=c("c"))) graph <- new("graphNEL", nodes=nodes, edgeL=edgeList, edgemode="directed") # subgraphs sgL <- list() sg1 <- subGraph(letters[1:4], graph) sg2 <- subGraph("f", graph) sgL[[1]] <- list(graph=sg1, attrs = c(label = "Subgraph A")) sgL[[2]] <- list(graph=sg2, attrs = c(label = "Subgraph B")) |
graphviz |
Rgraphviz |
gridGraphviz (old) |
gridGraphviz (new) |
|
# create Ragraph object rag <- agopen(graph, "", subGList=sgL, attrs=list(node=list(shape="ellipse"))) #plot plot(rag) |
library(gridGraphviz) # create Ragraph object rag <- agopen(graph, "", subGList=sgL, attrs=list(node=list(shape="ellipse"))) #plot grid.graph(rag) ## Warning: Unsupported node shape; using 'box' ## Warning: Unsupported node shape; using 'box' ## Warning: Unsupported node shape; using 'box' ## Warning: Unsupported node shape; using 'box' ## Warning: Unsupported node shape; using 'box' |
library(gridGraphviz) # create Ragraph object rag <- agopenTrue(graph, "", subGList=sgL, attrs=list(node=list(shape="ellipse"))) #plot grid.graph(rag) |
gridGraphviz (old) fails to produce ellipse shaped nodes, does not label or subgraphs, or place inside boxes.