I have the following code
g=load_graph("graph.xml")
clust=local_clustering(g)
for i in clust.get_array():
print i
This code returns something like
0.0
0.333333
1.5
....etc
What I would like to do is to print the vertex identifier that corresponds
to every clustering coefficient. The output to get is something like:
edge1 0.0
edge2 0.33333
edge3 1.5
.....etc.
I suppose that this is really simple, but I'm newbie at python I do not get
how to do it. I appreciate your help and comments.
Juan
attachment.html (602 Bytes)
Hi Juan,
Juan Manuel Tirado wrote:
What I would like to do is to print the vertex identifier that corresponds
to every clustering coefficient. The output to get is something like:
edge1 0.0
edge2 0.33333
edge3 1.5
.....etc.
I suppose that this is really simple, but I'm newbie at python I do not get
how to do it. I appreciate your help and comments.
This is indeed simple. All you have to do is iterate through the graph.
(I assume you mean "vertex" instead of "edge" above).
for v in g.vertices():
print int(v), clust[v]
This will print something line:
0 0.0
1 0.33333
2 1.5
...
Note also that the values of clust.get_array() are such that the i-th
value corresponds to the i-th vertex, where i is the vertex index.
Did I understand you question correctly?
Cheers,
Tiago
Thanks for the answer. Yes, this solves my "problem". As you can suppose,
I'm a newbie at Python.
Thank you so much.
Juan
Hi Juan,
attachment.html (1.65 KB)