【问题标题】:Visualize strongly connected components in R在 R 中可视化强连通分量
【发布时间】:2015-05-07 15:17:18
【问题描述】:

我有一个带有三个强连通分量 (SCC) 的加权有向图。 SCC 是从igraph::clusters 函数获得的

library(igraph)
SCC<- clusters(graph, mode="strong")  
SCC$membership
 [1] 9 2 7 7 8 2 6 2 2 5 2 2 2 2 2 1 2 4 2 2 2 3 2 2 2 2 2 2 2 2
SCC$csize
[1]  1 21  1  1  1  1  2  1  1
 SCC$no
[1] 9

我想用圆形和彩色背景来可视化 SCC,如下图所示,在 R 中有什么方法可以做到这一点?谢谢!

【问题讨论】:

  • 为了给您提供真正的答案,我们需要您的数据和一个最小的工作示例。另请参阅:stackoverflow.com/questions/5963269/…
  • 你看过igraph绘图函数的参数mark.groups吗:?plot.igraph

标签: r graph


【解决方案1】:

看看plot.igraphmark.groups 参数。像下面这样的东西可以解决问题:

# Create some toy data
set.seed(1)
library(igraph)
graph <- erdos.renyi.game(20, 1/20)

# Do the clustering
SCC <- clusters(graph, mode="strong")  

# Add colours and use the mark.group argument
V(graph)$color <- rainbow(SCC$no)[SCC$membership]
plot(graph, mark.groups = split(1:vcount(graph), SCC$membership))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-04
    • 2016-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多