4

In Pythons graph_tool, is there an easy way to calculate the weighted degree distribution (sum of the weights on out-going, in-coming, or all edges)?

In the Stats package, vertex_hist gives the un-weighted in-degree, out-degree, and total-degree histograms, but there doesn't seem to be a way to get the weighted version of these.

Note: I am working with 31,000 vertices and >10 million edges. I am looking for a way to do this utilizing graph_tool as as much as possible.

nobillygreen
  • 1,548
  • 5
  • 19
  • 27

1 Answers1

5

Yes, this is easy. You have to obtain a property map of the weighted degrees, and then do a histogram:

d = g.degree_property_map("out", weight)   # weight is an edge property map
bins = linspace(d.a.min(), d.a.max(), 40)  # linear bins
h = vertex_hist(g, d, bins)
Tiago Peixoto
  • 5,149
  • 2
  • 28
  • 28