Exercise

# Find nodes with top degree centralities

In this exercise, you'll take a deeper dive to see whether there's anything interesting about the most connected students in the network. First off, you'll find the cluster of students that have the highest degree centralities. This result will be saved for the next plotting exercise.

Instructions

**100 XP**

- Get the top 5
**unique**degree centrality scores. To do this, use the`sorted()`

function, in which the first argument is the**set**of degree centrality values of G (because you want*unique*degree centralities), and the second argument is`reverse=True`

, to ensure that it is sorted in descending order. To limit the results to the top 5 scores, add in appropriate slicing to the end of the statement. Also, remember to use`.values()`

on the returned degree centrality results! - Create list of nodes that have the top 5 highest overall degree centralities. To do this:
- Iterate over the dictionary of degree centrality scores using the
`.items()`

method on`nx.degree_centrality(G)`

. - If
`dc`

**is**in`top_dcs`

, then append the node`n`

to the`top_connected`

list.

- Iterate over the dictionary of degree centrality scores using the
- Print the number of nodes that share the top 5 degree centrality scores (
`top_connected`

) using`len()`

.