Degree centrality distribution of project nodes
Now it's time to plot the degree centrality distribution for the 'projects' partition of G. The steps to do this are exactly the same as in the previous exercise. For your convenience, matplotlib.pyplot has been pre-imported as plt.
Go for it!
Deze oefening maakt deel uit van de cursus
Intermediate Network Analysis in Python
Oefeninstructies
- Obtain a list called
project_nodescorresponding to the'projects'nodes ofG. - Using the
nx.degree_centrality()function, compute the degree centralities for each node inG. Store the result asdcs. - Use a list comprehension to compute the degree centralities for each node in
project_nodes. Store the result asproject_dcs. - Plot a histogram of the degree distribution of projects, using
plt.hist()andproject_dcs.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Get the 'projects' nodes: project_nodes
project_nodes = ____
# Compute the degree centralities: dcs
dcs = ____
# Get the degree centralities for project_nodes: project_dcs
project_dcs = [____]
# Plot the degree distribution of project_dcs
plt.yscale('log')
plt.hist(____, bins=20)
plt.show()