|
From: | Tamas Nepusz |
Subject: | Re: [igraph] Calculation of Coordination Number |
Date: | Sun, 17 Feb 2008 21:44:33 +0100 |
For instance, starting from the adjacency matrix, I first work out the connected components, then I would like to evaluate the mean degree (thanks for fixing my jargon) within each set of connected components.In Python: starting with your graph, you obtain a VertexClustering object somehow (I assume you already have it). Now, cl[0] gives the vertex IDs in the first component, cl[1] gives the vertex IDs in the second and so on. If the original graph is called g, then g.degree(cl[0]) gives the degrees of those vertices, so the average degrees in each connected component are as follows (I'm simply iterating over the components in a for loop):What is the most efficient way of doing this
cl=g.components() for idx, component in enumerate(cl): degrees = g.degree(component) print "Component #%d: %s" % (idx, sum(degrees)/float(len(degrees))) -- T.
[Prev in Thread] | Current Thread | [Next in Thread] |