I have a homework that need to call Networkx's function to get the degrees of all the nodes, and then draw a boxplot for these degrees.
But the boxplot is not show and have a error below:
"degree_values = list(my_degrees.values());
AttributeError: 'DegreeView' object has no attribute 'values'"
How to solve this problem? Thanks.
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
G.add_edges_from([['9606.EN01','9606.EN02'],['9606.EN01','9606.EN03']])
fig = plt.figure();
nx.draw(G, with_labels=True, font_weight='bold')
plt.draw()
my_degrees = G.degree();
degree_values = list(my_degrees.values());
fig = plt.figure();
plt.boxplot(degree_values)