igraph-help
[Top][All Lists]

## [igraph] Creating subgraphs on the basis of clusters()

 From: MATSUDA, Noriyuki Subject: [igraph] Creating subgraphs on the basis of clusters() Date: Fri, 14 Dec 2007 11:35:40 +0900

```Hello:

I need help in creating subgraphs by selecting clusters of certain sizes.  To
do so, I want to obtain the list of memberships of the vertices to be selected.
-------------------------------------------------------------------------------------------------------------------
a <- c(0,1)
b <- c(2,3,3,4)
c <- c(5,6,5,7,6,7)
d <- c(8,9,8,10,8,11, 9,10,9,11, 10,11)
e <- c(12,13,12,15, 13,14, 14,15, 15,16)
g<- graph(c(a,b,c,d,e),directed=F)
plot(g, layout= layout.circle) #vertex.label=V(g)\$name
cls<- clusters(g)
# \$membership
#  [1] 0 0 1 1 1 2 2 2 3 3 3 3 4 4 4 4 4
# \$csize
```
# [1] 2 3 3 4 5 #e.g., the membership & the size of the first cluster are 0 & 2
```
clsID<- which(cls\$size == 2) - 1     # resulting in a single value 0
which(cls\$membership == clsID)  # 1, 2
clsID<- which(cls\$csize == 3) - 1  # resulting in a vector consisted of 1 & 2
which(cls\$membership == clsID)  # resulting in 0 0 which are hard to interpret.
-------------------------------------------------------------------------------------------------------------------

Is there a way to specify the condition like cls\$membership in clsID ?
--
MATSUDA, Noriyuki　<in Kanji> 松 田 紀 之

```