I have a graph G in networkx and would like to sort the nodes according to their degree. However, the following code does not work in latest networkx versions:
sorted(set(G.degree().values()))
and the following seems a bit clunky as it requires converting the networkx DegreeView to a python list of tuples
degrees = [(node,val) for (node, val) in G.degree()]
sorted(degrees, key=lambda x: x[1], reverse=True)
is there any better way?
The following works:
sorted(G.degree, key=lambda x: x[1], reverse=True)