[igraph] degree distribution

134 views
Skip to first unread message

四正(红砖)

unread,
Jun 12, 2013, 7:27:10 PM6/12/13
to igraph-help
Hi folks,

I'm using igraph in python.

the function degree_distribution returns a instance of Histogram.

How can I see the individual values in it, please?

It always says "TypeError: 'float' object cannot be interpreted as an integer" when I call some functions such as to_string(). I think it is because the values of degree distribution is probabilities in float.

Thanks a lot.

Gang

Tamás Nepusz

unread,
Jun 13, 2013, 1:40:02 AM6/13/13
to Help for igraph users
Hi,

There was a bug in the Histogram class that has been fixed recently; basically, the __len__ method returned a float value incorrectly instead of an integer. The fix involves simply replacing one line in igraph/statistics.py:

https://github.com/igraph/igraph/commit/73b5234

This should solve your problem. Alternatively, you can stop using the degree_distribution() method and do this instead:

from collections import Counter
dd = Counter()
for d in g.degrees():
dd[d] += 1

Then you can simply use the methods of the standard Python Counter class to query the values in the degree distribution.

--
T.

> _______________________________________________
> igraph-help mailing list
> igrap...@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/igraph-help


_______________________________________________
igraph-help mailing list
igrap...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply all
Reply to author
Forward
0 new messages