On Thu, Mar 31, 2011 at 5:18 AM, Tamas Nepusz
<address@hidden> wrote:
> 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.
_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help