Union of igraph objects loses attributes

前端 未结 1 1374
悲&欢浪女
悲&欢浪女 2020-12-21 15:41

I have two igraph objects, which have different color attributes. Vertices \"A\" and \"B\" in first graph are colored red. Vertices <

相关标签:
1条回答
  • 2020-12-21 16:17

    igraph doesn't loose the colors, it stores them in $color_1 and $color_2. I think this is because in the general case there might be common vertices with different colors. What would you do then?

    Try this:

    V(graph)$color <- ifelse(is.na(V(graph)$color_1),
                             V(graph)$color_2,V(graph)$color_1)
    plot(graph)
    

    BTW: your code didn't run for me. I had to use:

    graph <- graph.union(graph.1, graph.2, byname=T)
    
    0 讨论(0)
提交回复
热议问题