简体   繁体   中英

Color network nodes according to attribute using igraph in R while simultaneously displaying Girvan Newman communities

I am trying to display a social network with Girvan Newman communities using igraph in R. I additionally want to distinguish the nodes according to attribute data (eg, male nodes blue, female nodes pink). I know how to do this in a typical graph, but I'm having trouble executing this successfully while using the Girvan Newman algorithm. Here is my code so far:

    fgn = edge.betweenness.community (fmg, directed = TRUE, edge.betweenness = TRUE, merges = TRUE, bridges = TRUE, modularity = TRUE, membership = TRUE)

    plot(fgn,fmg) 

If I were simply plotting the network without employing the Girvan Newman algorithm, I would distinguish the nodes in this way:

    V(fmg)[V(fmg)$gender== 1]$color <- "dodgerblue"
    V(fmg)[V(fmg)$gender== 2]$color <- "pink"

Unfortunately, I'm not sure how to distinguish the nodes appropriately while using the algorithm, though I've tried. Any specific advice would be much appreciated.

Welcome to stackoverflow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM