igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Clusters question


From: Gábor Csárdi
Subject: Re: [igraph] Clusters question
Date: Thu, 5 Apr 2012 21:56:18 -0400

On Thu, Apr 5, 2012 at 9:38 PM, Ish Rattan <address@hidden> wrote:
>
> I have graph with 88000 vertices and 5100000 edges.
>
> I would like to have access to size of each cluster and number of clusters.
> Looks like cl[len(cl)-1] and cl[len(cl)-2] do not have
> this information so where could it be in cl?

Please read what Tamas wrote, the answers to your questions are in his email.

G.

> -ishwar
>
>
> On Fri, 6 Apr 2012, Tamás Nepusz wrote:
>
>>> print g.clusters("strong")
>>> <igraph.clustering.VertexClustering object at 0x8defc8c>
>>>
>>> Now, how do I acces the members of this object: eg, size of components,
>>> count of components etc?
>>
>>
>> VertexClustering has a couple of methods that let you do that. First, you
>> can use VertexClustering as a list, in which case you get the vertex IDs of
>> the vertices in each component:
>>
>> cl = g.clusters("strong")
>> cl[0]     # gives you the first component
>> cl[1]     # gives you the second component
>> len(cl)  # gives you the number of components
>>
>> You can also iterate over it as if it were a list:
>>
>> for component in cl:
>>   print component
>>
>> It also has a "membership" property that returns a vector in which element
>> i contains the index of the component in which vertex i participates:
>>
>> print cl.membership
>>
>> If you need the subgraph corresponding to a given connected component (and
>> not just a list of vertex IDs), use the subgraph() method of the
>> VertexClustering:
>>
>> g2 = cl.subgraph(0)     # returns the first component as another Graph
>> object
>>
>> Finally, VertexClustering also has a method called sizes(), which returns
>> the sizes of each component. For more information, type help(Clustering) and
>> help(VertexClustering).
>>
>> Hope this helps.
>>
>> Best,
>> Tamas
>>
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://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]