Note
Go to the end to download the full example code.
Cliques
This example shows how to compute and visualize cliques of a graph using igraph.GraphBase.cliques().
import igraph as ig
import matplotlib.pyplot as plt
First, let’s create a graph, for instance the famous karate club graph:
g = ig.Graph.Famous("Zachary")
Computing cliques can be done as follows:
cliques = g.cliques(4, 4)
We can plot the result of the computation. To make things a little more interesting, we plot each clique highlighted in a separate axes:
fig, axs = plt.subplots(3, 4)
axs = axs.ravel()
for clique, ax in zip(cliques, axs):
ig.plot(
ig.VertexCover(g, [clique]),
mark_groups=True,
palette=ig.RainbowPalette(),
vertex_size=5,
edge_width=0.5,
target=ax,
)
plt.axis("off")
plt.show()