Igraph in R: how to change edge color based on edge attribute -


i trying generate igraph in r. want edge color dependent on edge attribute - department. cannot use ifelse statement because department values can dynamic. can find number of unique departments, not sure how proceed further in creating different edge colors different departments.

    department= unique(edges$department)     department.count=length(department) 

example code:

    gg <- graph.atlas(711)     v(gg)$name=1:7     gg=set_edge_attr(gg,"department",e(gg)1:10],c("a","b","c","a","e","c","g","b","c","a"))     e(gg)$label=e(gg)$department     plot(gg) 

i want have different colors each edge, depending on values of department in edge. 'a' departments in 1 color , b department edges in color , on. kindly help.

you should provide small reproducible example when posting. said, should able setting color attribute of edges:

e(testgraph)$color <- as.factor(edges$department) 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -