here is my code and the text file is here
import networkx as nx
import pylab as plt
webg = nx.read_edgelist('web-graph.txt',create_using=nx.DiGraph(),nodetype=int)
in_degrees = webg.in_degree()
in_values = sorted(set(in_degrees.values()))
in_hist = [in_degrees.values().count(x)for x in in_values]
I want to plot degree distribution web graph how can i change dict to solve?
In Python3 dict.values()
returns "views" instead of lists:
- dict methods dict.keys(), dict.items() and dict.values() return "views" instead of lists. https://docs.python.org/3/whatsnew/3.0.html
To convert the "view" into a list, simply wrap in_degrees.values()
in a list()
:
in_hist = [list(in_degrees.values()).count(x) for x in in_values]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With