Get degree of each nodes in a graph by Networkx in python

You are using version 2.0 of networkx. Which changed from using a dict for G.degree() to using a dict-like (but not dict) DegreeView. See this guide.

To have the degrees in a list you can use a list-comprehension:

degrees = [val for (node, val) in G.degree()]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)