set.seed(123)
V <- letters[1:10]
M <- 1:4
g1 <- randomGraph(V, M, .2)
nAttrs <- list()
eAttrs <- list()
nAttrs$label <- c(a="lab1", b="lab2", g="lab3", d="lab4")
eAttrs$label <- c("a~h"="test", "c~h"="test2")
nAttrs$color <- c(a="red", b="red", g="green", d="blue")
eAttrs$color <- c("a~d"="blue", "c~h"="purple")
toDot(g1, tempfile(), nodeAttrs=nAttrs, edgeAttrs=eAttrs)
Run the code above in your browser using DataLab