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: Gábor Csárdi
Subject: Re: [igraph] about input file for igraph_clusters( )
Date: Thu, 31 Mar 2011 14:17:50 -0400

On Thu, Mar 31, 2011 at 10:15 AM, Yi Cao <address@hidden> wrote:
> 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.

I would create a vector for the components, fill it with zero, and
then iterate over the vertices in your first column, check which
component they are in, and then increase the corresponding cell of the
histogram.

Gabor

>
> Regards,
> Yi
>
> 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
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



-- 
Gabor Csardi <address@hidden>     MTA KFKI RMKI



reply via email to

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