Finding cliques (I)

Introduction to Network Analysis in Python

Eric Ma

Data Carpentry instructor and author of nxviz package

Cliques

  • Definition:
    • Groups of nodes
    • Fully connected
  • Simplest clique: edge
  • Simplest complex clique: triangle
Introduction to Network Analysis in Python

Maximal cliques

  • Definition:
    • A clique
    • Cannot be extended by adding a node
Introduction to Network Analysis in Python

Finding cliques

import networkx as nx
G = nx.erdos_renyi_graph(n=100, p=0.15)

nx.find_cliques(G)
<generator object find_cliques at 0x10ca8bca8>
for clique in nx.find_cliques(G):
    print(len(clique))
Introduction to Network Analysis in Python

Let's practice!

Introduction to Network Analysis in Python

Preparing Video For Download...