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

Connected

Exercise

Matrix plot

Let's now practice making some visualizations. The first one will be the Matrix plot. In a Matrix plot, the matrix is the representation of the edges.

Instructions

100 XP
  • Make a Matrix plot visualization of the largest connected component subgraph, with authors grouped by their user group number.
    • First, calculate the largest connected component subgraph by using the nx.connected_components(G) inside the provided sorted() function. Python's built-in sorted() function takes an iterable and returns a sorted list (in ascending order, by default). Therefore, to access the largest connected component subgraph, the statement is sliced with [-1].
    • Create the matrix plot h. You have to specify the parameters graph and group_by to be the largest connected component subgraph and 'grouping', respectively.
    • Draw the matrix plot to the screen.