[Top][All Lists]

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

Re: [igraph] Clusters question

From: Ish Rattan
Subject: Re: [igraph] Clusters question
Date: Thu, 5 Apr 2012 22:14:03 -0400 (EDT)

Please ignore my previous message, I figured it out.

One more question, if I try (in R with igraph):

  g <- read.graph("list.txt", format="edgelist")

the interpreter prompt does not come back!

The graph is huge 87000 vertices and 5100000 edges.

Is it that I did not wait long enough for the read to complete?


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 

Hope this helps.


igraph-help mailing list

reply via email to

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