Session Ready
Exercise

Deep dive - Twitter network

You're going to now take a deep dive into a Twitter network, which will help reinforce what you've learned earlier. First, you're going to find the nodes that can broadcast messages very efficiently to lots of people one degree of separation away.

NetworkX has been pre-imported for you as nx.

Instructions
100 XP
  • Write a function find_nodes_with_highest_deg_cent(G) that returns the node(s) with the highest degree centrality using the following steps:
    • Compute the degree centrality of G.
    • Compute the maximum degree centrality using the max() function on list(deg_cent.values()).
    • Iterate over the degree centrality dictionary, deg_cent.items().
    • If the degree centrality value v of the current node k is equal to max_dc, add it to the set of nodes.
  • Use your function to find the node(s) that has the highest degree centrality in T.
  • Write an assertion statement that checks that the node(s) is/are correctly identified. This has been done for you, so hit 'Submit Answer' to see the result!