[Top][All Lists]

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

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

From: Yi Cao
Subject: Re: [igraph] about input file for igraph_clusters( )
Date: Thu, 31 Mar 2011 10:15:51 -0400

Hello Tamas,
Thanks for your idea. Probably I did not make clear what I wanted to do. I want to calculate the histogram of component size for vertices in first column. or in other words, for each cluster, i want to know the number of vertices in this cluster which are also in first column, and then i make the histogram of component size. the method you suggested works, but if i need lots of vector members to store the result, right? so, this may be difficult.


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)

Completely untested, but you get the idea.


igraph-help mailing list

reply via email to

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