igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] about input file for igraph_clusters( )


From: Tamas Nepusz
Subject: Re: [igraph] about input file for igraph_clusters( )
Date: Thu, 31 Mar 2011 11:18:13 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8

>       Now I want to know exactly  the component id for each vertex in
> set A and the corresponding component size.  Because the
> igraph_cluster( )store the component id for each vertex in  membership
> and the component size in csize, I need to pick out the component ids
> and corresponding size for vertices in set A from vector membership
> and component size. Before I can do this, I need pick out and record
> the vertices id in set A. So, I was trying to write a piece of code to
> do this for me, but I got stuck with this. Anyone gets some ideas
> about this?
You only have to iterate over the membership vector and record the
indices of the elements that are equal to the index of the cluster you
are interested in. For instance, to get the members of cluster 2:

std::vector<long> members;
long int i, n = igraph_vector_size(&membership);
for (i = 0; i < n; i++) {
  if (VECTOR(membership)[i] == 2)
    members.push_back(i);
}

Completely untested, but you get the idea.

-- 
T.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]