configuration model random - average_clustering value

62 views
Skip to first unread message

Amitabh Sharma

unread,
Jul 3, 2011, 1:36:48 AM7/3/11
to networkx...@googlegroups.com
I am trying to create random based on configuration model and calculate  for these random average clustering coefficient values:
I am getting this error:

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)

/home/amitabh/common/random-modle_1.py
     44         m=len(cluster_list[0])
     45         list1.append(m)
---> 46         clustering_r= (nx.average_clustering(g))
     47         #print ("random",i,(list1))
     48         print ("random",i,(list2))

/usr/lib/python2.4/site-packages/networkx/algorithms/cluster.pyc in average_clustering(G)
     85     """
     86     order=G.order()
---> 87     s=sum(clustering(G))
     88     return s/float(order)
     89

/usr/lib/python2.4/site-packages/networkx/algorithms/cluster.pyc in clustering(G, nbunch, with_labels, weights)
    140             clusterc[v]=0.0
    141         else:
--> 142             clusterc[v]=t/float(d*(d-1))
    143
    144     if with_labels:

ZeroDivisionError: float division

Can you how to correct this!

A

Dan Schult

unread,
Jul 3, 2011, 9:53:50 AM7/3/11
to networkx...@googlegroups.com
What version of networkx are you using? It looks like you've got
Python 2.4 (which isn't supported by the latest networkx version
anymore).
Try print networkx.__version__

The problem with the clustering routine is that somehow you are getting
degree zero or one nodes to have nonzero number of triangles. It's hard
to tell how that would happen, but it might be a mismatch in versions.

Dan

> --
> You received this message because you are subscribed to the Google
> Groups "networkx-discuss" group.
> To post to this group, send email to networkx-
> dis...@googlegroups.com.
> To unsubscribe from this group, send email to networkx-discuss
> +unsub...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/
> group/networkx-discuss?hl=en.

Reply all
Reply to author
Forward
0 new messages