graph-theory representation-learning
Definition
Weisfeiler-Leman Algorithm
The Weisfeiler-Leman algorithm is an iterative procedure used to test for graph isomorphism and generate structural embeddings. Formally, given a graph with initial vertex colours , the algorithm update rule for iteration is:
where is the set of neighbours of , and denotes a multiset. The process terminates when the partition of vertices induced by the colours remains stable.
Applications in Machine Learning
Expressive Power of GNNs: The message-passing mechanism in standard Graph Neural Networks is a differentiable generalisation of the WL-algorithm. The WL-test provides a theoretical upper bound on the ability of GNNs to distinguish non-isomorphic graph structures.
Graph Kernels: The WL-kernel measures similarity between graphs by comparing the distribution of vertex colours across multiple refinement iterations.
Algorithm Properties
Incompleteness: The WL-algorithm is a necessary but not sufficient test for graph isomorphism. Certain pairs of non-isomorphic graphs (e.g., strongly regular graphs) cannot be distinguished by the 1-WL test.
Efficiency: The procedure is highly scalable, requiring only linear time complexity per iteration with respect to the number of edges.
Example
Simple Example
Consider a path graph with .
Step 0 (Initialisation): All vertices are assigned the same initial colour .
Step 1 (First Iteration): Colours are updated based on neighbour multisets. Terminal nodes (1, 4) receive colour 2, while internal nodes (2, 3) receive colour 3.
Step 2 (Convergence): The algorithm checks if the partition changes. Since nodes with colour 2 still see the same neighbour colour distribution (one 3), and nodes with colour 3 see (one 2, one 3), the partition into and is stable.
Complex Example
Consider the “House Graph” which demonstrates how the algorithm refines colours beyond just vertex degrees.
Step 0 (Initialisation): All vertices start with the same colour.
Step 1 (First Iteration): Nodes are coloured by degree. Vertices have degree 2 (colour 2), while have degree 3 (colour 3).
Step 2 (Second Iteration): Nodes now look at the “types” of neighbours they have from the previous step:
- and : Each has one neighbour of colour 2 and one of colour 3.
- : Both of its neighbours are colour 3.
Because sees a different “neighbourhood” than and , it realised it is structurally different and gets its own unique colour (6).
Step 3 (Convergence): The partition remains stable as . No further refinement is possible.