How can I color the graphNEL graph nodes?

I use graphNEL objects from gRbase and Rgraphviz to plot the graph and would like to color the graph nodes in different (specified) colors when plotting. For example, how could I plot this graph with a and b blue and c and d red?

 library(Rgraphviz) library(gRbase) mygraph = dag(~a:c + b:c + b:d) plot(mygraph) 

enter image description here

+6
source share
1 answer

This should work;

 nAttrs<-list() nAttrs$color <- c(a = "blue", b = "blue", c = "red", d = "red") plot(g1, nodeAttrs = nAttrs) 

see also getDefaultAttrs() to get all graph attributes with default values.

+7
source

All Articles