简体   繁体   English

根据属性使用igraph在R中同时显示Girvan Newman社区的颜色网络节点

[英]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). 我正在尝试使用R中的igraph显示与Girvan Newman社区的社交网络。我还想根据属性数据区分节点(例如,男性节点蓝色,女性节点粉红色)。 I know how to do this in a typical graph, but I'm having trouble executing this successfully while using the Girvan Newman algorithm. 我知道如何在典型的图形中执行此操作,但在使用Girvan Newman算法时我无法成功执行此操作。 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: 如果我只是在不使用Girvan Newman算法的情况下绘制网络,我会以这种方式区分节点:

    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. 欢迎来到stackoverflow。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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