2013-12-22 86 views
2

我應該在羣集中找到弱羣集和節點的成員資格,以及羣集中節點的強羣集和成員身份。找到強羣集和弱羣集及其在R中的成員身份

我的代碼:

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) 

至於解決辦法,我得到這個:

> 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 

但我沒有得到這是我堅強的集羣,我我怎麼能畫出我的強烈集羣不同的顏色? R studio有什麼好的教程,因爲R studio沒有太多的資源?

回答

6

的集羣是在clusters(g, mode="strong")

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

membership一部分,他們是在你的節點的順序圖中的例如

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 

顏色,這些在你的情節做這樣的事情:

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

enter image description here

+0

感謝您的幫助:),這是否意味着在這個種子,強大的集羣是其成員3, 4或5?並有任何顯示強羣集數量的功能嗎? –

+1

(強)簇的數量在上面的輸出中,位於'$ no'下。或者,'no.clusters'的輸出也是如此。你覺得這個功能在做什麼? –

+0

@Gabor Csardi,我在考慮在繪製的圖表上顯示一些內容,比如下面的圖片,強大的羣集數量和他們的成員資格,抱歉我的問題是不可理解的。 –