Finding cliques (II)
Great work! Let's continue by finding a particular maximal clique, and then plotting that clique.
This exercise is part of the course
Introduction to Network Analysis in Python
Exercise instructions
- Find the author(s) that are part of the largest maximal clique, and plot the subgraph of that/one of those clique(s) using a Circos plot. To do this:
- Use the
nx.find_cliques()
function to calculate the maximal cliques inG
. Place this within the providedsorted()
function to calculate the largest maximal clique. - Create the subgraph consisting of the largest maximal clique using the
.subgraph()
method andlargest_clique
. - Create the
Circos plot
object using the subgraphG_lc
(without any other arguments) and plot it.
- Use the
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import necessary modules
import networkx as nx
from nxviz import circos
import matplotlib.pyplot as plt
# Find the author(s) that are part of the largest maximal clique: largest_clique
largest_clique = sorted(____, key=lambda x:len(x))[-1]
# Create the subgraph of the largest_clique: G_lc
G_lc = ____
# Create the Circos plot: c
c = ____
# Draw the Circos plot to the screen
____
plt.show()