emax
emax

Reputation: 7245

Python: how to calculate in-degree and out-degree distribution from a networkx Graph

I created a directed graph using the networkx package.

G = nx.DiGraph()

In order to compute the degree distribution I just do:

x = list(nx.degree(G).values())
counts, bin_edges = np.histogram(x)

How can I get the in_degree and out_degree distributions?

Upvotes: 0

Views: 2711

Answers (1)

DYZ
DYZ

Reputation: 57033

Call G.in_degree and G.out_degree instead of nx.degree.

Upvotes: 1

Related Questions