1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Network Analysis in Python

Exercise

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!

Instructions

100 XP
  • Obtain a list called project_nodes corresponding to the 'projects' nodes of G.
  • Using the nx.degree_centrality() function, compute the degree centralities for each node in G. Store the result as dcs.
  • Use a list comprehension to compute the degree centralities for each node in project_nodes. Store the result as project_dcs.
  • Plot a histogram of the degree distribution of projects, using plt.hist() and project_dcs.