Finding Strong and Weak Clusters and their membership in R

谁都会走 提交于 2019-12-06 11:53:07

问题


I should find weak clusters and membership of the nodes in the clusters, and strong clusters and membership of the nodes in the clusters.

My code :

library(igraph)
g <- erdos.renyi.game(8, 15/100)
is.connected(g, mode=("strong"))
clusters(g, mode="strong")
no.clusters(g, mode="strong")
cluster.distribution(g, cumulative = FALSE, mul.size = FALSE)

As solution I got this :

> library(igraph)
> g <- erdos.renyi.game(8, 15/100)
> is.connected(g, mode=("strong"))
[1] FALSE
> clusters(g, mode="strong")
$membership
[1] 1 2 1 1 3 1 4 1

$csize
[1] 5 1 1 1

$no
[1] 4

> no.clusters(g, mode="strong")
[1] 4
> cluster.distribution(g, cumulative = FALSE, mul.size = FALSE)
[1] 0.00 0.75 0.00 0.00 0.00 0.25

But I didnt get which are my strong clusters, and i how can i plot my strong clusters in different color? Is there any good tutorial for R studio , coz there are no many sources for R studio?


回答1:


The clusters are in the membership part of clusters(g, mode="strong")

set.seed(247)
library(igraph)
g <- erdos.renyi.game(8, 15/100)

They are in the order of your nodes in the graph e.g.

V(g) # the nodes in your graph are 1-8
#Vertex sequence:
#[1] 1 2 3 4 5 6 7 8

# the respective cluster for nodes 1-8 are:
clusters(g, mode="strong")$membership
#[1] 1 2 3 1 1 4 5 2

To colour these in your plot do something like:

strongclusters <- clusters(g, mode="strong")$membership
plot(g, vertex.color = strongclusters)



来源:https://stackoverflow.com/questions/20725411/finding-strong-and-weak-clusters-and-their-membership-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!