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

Connected

Exercise

Visualize the degree centrality distribution of the students projection

In this exercise, you will visualize the degree centrality distribution of the students projection. This is a recap of two previous concepts you've learned: degree centralities, and projections.

Instructions

100 XP
  • Get the nodes of the 'student' partition into a list called student_nodes.
    • Use a list comprehension to do this, iterating over all the nodes of G (including the metadata), and checking to see if the 'bipartite' keyword of d equals 'student'.
  • Create the students nodes projection as a graph called G_students. Use the nx.bipartite.projected_graph() function to do this. Be sure to specify the keyword argument nodes=student_nodes.
  • Calculate the degree centrality of G_students using nx.degree_centrality(). Store the result as dcs.
  • Plot the histogram of degree centrality values.