[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Python Interface to igraph
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Python Interface to igraph |
Date: |
Fri, 8 Feb 2008 23:08:56 +0100 |
Shouldn't g.clusters() return the membership of each node to a
cluster? Am I doing anything wrong? On my machine, g.clusters()
returns what looks like a memory address.
g.clusters() returns an object with class VertexClustering (see the
documentation or type help(Graph.clusters)). When you simply try to
print this object, Python reports its class and its memory address.
What you probably wanted based on your previous R experiences is the
membership vector that's stored in an instance variable called
membership. E.g.:
g=Graph.Erdos_Renyi(100, 0.1)
cl=g.clusters()
print cl.membership
The VertexClustering class has the following features:
len(cl) returns the number of clusters (if cl is a VertexClustering
object)
cl[0] returns the members of the first cluster
cl[1] returns the members of the second cluster
...and so on
cl.membership returns the membership vector that you got used to when
using the R interface
cl.q returns the modularity of the given partition
Cheers,
--
Tamas