Assumptions¶
- Vertex ids are independent of what we are trying to predict
- For instance, vertex ids are given at random
Reynolds Operator (Symmetrization) in Graph Representation Learning¶
(Murphy et al., 2019b) gave the following (then) surprising result denoted Relational Pooling, a graph neural representation defined as $$ \Gamma(A) = \frac{1}{n!} \sum_{\pi \in \mathbb{S}_n} f(\pi \circ A), $$ where $f: \mathbb{A}^{n^2} \times V \to \mathbb{R}^{n \times d}$ is an arbitrary learnable function (e.g., neural network) that outputs a $d$-dimensional node representation for each node $i\in V$ in graph $A \in \mathbb{A}^{n^2}$.
Theorem 2.1 (Murphy et al., 2019b) If node and edge attributes come from a finite set and $f: \mathbb{A}^{n^2} \to \mathbb{R}^{n \times d}$ is an universal function approximator, then $$ \Gamma(A) = \frac{1}{n!} \sum_{\pi \in \mathbb{S}_n} f(\pi \circ A) $$ is a most-expressive equivariant graph representation for each node $i\in V$ in graph $A \in\mathbb{A}^{n^2}$.
- For instance, $f$ could be an MLP, a convolutional neural network (CNN), or any sequence model (e.g., Transformers).
1.1 Symmetrization of Equivariant Linear Layers for Graph Learning¶
(Maron et al., 2019a)
Definition: Equivariant linear layers are neural network layers designed to respect symmetries in graph-structured data, ensuring that transformations of inputs (e.g., node permutations) induce corresponding transformations on outputs. Formally, a layer $L$ is equivariant under the action of a group $G$ (e.g., the permutation group $S_n$) if:
$$
L(\pi \circ {\bf A}) = \pi \circ L({\bf A}), \quad \forall \pi \in G,
$$
where ${\bf A} \in \mathbb{A}^{n\times n}$ is our adjacency tensor and $\pi \circ {\bf A}$ denotes the permuted input.
Key Insight: While relational pooling (above) achieves equivariance by averaging over all permutations of arbitrary functions, as we have seen before, equivariace on linear layers can be obtained through the Reynolds operator.
Construction: Maron et al. (2019a) propose a framework for constructing such layers by solving a system of linear equations. Here, we will present a simpler construction based on the 1-left-eigenvectors of the Reynolds operator.
We now obtain equivariant linear layers.
- Those layers are applied to our adjacency tensor ${\bf A} \in \mathbb{A}^{n \times n}$.
- It can be shown that stacking those layers leads to architectures that are universal, for sufficiently large number of such layers.
Notation:
- Let ${\bf W} \in \mathbb{R}^{n\times n^2}$ denote our neuron weights.
- Let $\pi \in \mathbb{S}_n$ be an element of the symmetric group of order $n$ (a pemutation) and let $\rho_2: \mathbb{S}_n \to \mathbb{R}^{n^2 \times n^2}$ be a representation of $\pi$ that acts on the (vectorized) adjacency matrix to permute it, i.e., $\rho_2(\pi)\text{vec}({\bf A}) $ is a (vectorized) permutation of ${\bf A}$. And let $\rho_1: \mathbb{S}_n \to \mathbb{R}^{n \times n}$ be a permutation of the $n$ neuron outputs, one for each node.
Then, from our G-equivariance and set lectures, we know that G-equivariance implies $$\begin{equation}\tag{8} \forall \pi \in \mathbb{S}_n, \forall {\bf A} \in \mathbb{A}^{n \times n}:\quad \rho_1(\pi){\bf W}\text{vec}({\bf A}) = {\bf W}\rho_2(\pi)\mathrm{vec}({\bf A}) \end{equation}$$ where $\mathrm{vec}$ flattens the matrix into a vector.
Since Equation $(8)$ is true for all ${\bf A}$, we can impose the following: $$ \rho_1(\pi){\bf W} = {\bf W}\rho_2(\pi). $$
We can now use the Kronecker product property we saw in our G-equivariance lecture and in our set lecture to write $$ \rho_1(\pi){\bf W} = {\bf W}\rho_2(\pi) \implies \rho_1(\pi)\otimes \rho_2(\pi^{-1})^T\mathrm{vec}({\bf W}) = \mathrm{vec}({\bf W}). $$
For any permutation $\pi \in \mathbb{S}_n$ the permutation matrix is such that $\rho(\pi^{-1}) = \rho(\pi)^T$. Then, $$ \rho_1(\pi){\bf W} = {\bf W}\rho_2(\pi) \implies \rho_1(\pi)\otimes \rho_2(\pi)\mathrm{vec}({\bf W}) = \mathrm{vec}({\bf W}). $$
Finally, we need to compute the Reynolds operator $$\bar{P} = \sum_{\pi \in \mathbb{S}_n} \rho_1(\pi)\otimes \rho_2(\pi).$$ And we know from our G-invariance lecture that the Reynolds operator guarantees $\rho_1(\pi)\otimes \rho_2(\pi) = \bar{P}$, $\forall \pi \in \mathbb{S}_n$.
We now define the subspace of neuron parameters that will make our (linear) neural layer equivariant.
As seen in the G-invariant lecture, weights $$\mathrm{vec}({\bf W}) \in \text{Left-1-Eig}(\bar{P}) = \{\mathrm{vec}({\bf W}') \in \mathbb{R}^{n^4} : \mathrm{vec}({\bf W}')^T \bar{P} = \mathrm{vec}({\bf W}')^T \}$$ define an equivariant subspace.
Moreover, we know $\text{Left-1-Eig}(\bar{P})$ is span by the left eigenvectors of $\bar{P}$ with eigenvalue 1, therefore our neuron weights are defined as $$ \mathrm{vec}({\bf W}) = \sum_{i=1}^k \alpha_i {\bf v}_i^T, $$ where ${\bf v}_1^T,\ldots,{\bf v}_k^T$ are the $k$ left eigenvectors of $\bar{P}$, where $k$ is the rank of $\bar{P}$.
For example, the 1-left eigenvector basis for ${\bf A} \in \mathbb{A}^{n \times n}$ for $n = 5$ can be visualized as
import itertools
import numpy as np
import scipy
from copy import deepcopy
n = 5
# Empty adjacency matrix
A = np.zeros((n,n))
# Vectorizes matrix
vA = A.flatten()
I = np.eye(n)
import math
n_factorial = math.factorial(n)
# Reynolds operator matrix to obtain an invariant representation for the entire graph
Tbar = []
Tbar_b = None
from scipy.linalg import block_diag
# Get Reynolds operator matrix
# We will partition the permutation group S_n into n cosets, where each coset fixes one element (j) in position j
# For each j, we compute a partial Reynolds operator Tbar[j] that averages over permutations where j stays fixed
# We will then combine these n partial operators using block_diag(*Tbar)*n
# Because of the equivariance requirement, the final Tbar_b matrix will be n^3 size
for j in range(n):
Tbar.append(np.zeros((n**2,n**2)))
for i in range(n**2):
A[i // n, i % n] = 1
# Permute just n-1 elements, since j is fixed
for idx in itertools.permutations(list(range(n-1))):
# Get the permutation of matrix A
idx0 = np.asarray(idx)
if j == n-1:
idx0[idx0 == j] = 0
else:
idx0[idx0 == j] = n-1
# Add permutation where j becomes node n (n-1 since we start from 0)
idx0 = np.insert(idx0[idx0 != j],j,[j])
myT = A[:,idx0]
myT = myT[idx0,:]
# This is the i-th row of the permutation matrix
Tbar[j][i,:] += myT.flatten()/n_factorial
# Count towards the number of elements in the permutation group
# Note that we are counting all rows of Tbar for every permutation matrix n^2
A[i // n, i % n] = 0
Tbar_b = block_diag(*Tbar)*n
print('Change the value of n and observe a pattern emerge (i.e., we can directly construct Tbar)')
print(f'The Reynolds operator Tbar is a {Tbar_b.shape[0]}x{Tbar_b.shape[1]} matrix:\n {Tbar_b}')
Change the value of n and observe a pattern emerge (i.e., we can directly construct Tbar) The Reynolds operator Tbar is a 125x125 matrix: [[1. 0. 0. ... 0. 0. 0. ] [0. 0.25 0.25 ... 0. 0. 0. ] [0. 0.25 0.25 ... 0. 0. 0. ] ... [0. 0. 0. ... 0.25 0.25 0. ] [0. 0. 0. ... 0.25 0.25 0. ] [0. 0. 0. ... 0. 0. 1. ]]
eigenvalues, eigenvectors = np.linalg.eigh(Tbar_b)
#print(f'eigenvalues={eigenvalues}\n')
# Find the rank of Tbar (here, equivalent to the number of eigenvectors with eigenvalue 1).
rank = np.linalg.matrix_rank(np.diag(eigenvalues), hermitian=True)
print(f'Rank of Tbar of size {Tbar_b.shape[0]} x {Tbar_b.shape[1]}: {rank}')
# Eigenvectors with eigenvalue 1 (eigenvalues are arranged in ascending order).
one_eigenvectors = eigenvectors[:, -rank:]
Rank of Tbar of size 125 x 125: 25
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
import math
# Let's see the bases in the form of an n×n² matrix with vertical lines
fig, axes = plt.subplots(nrows=((rank-1)//3 + 1), ncols=3, figsize=(15, 12), sharex='all', sharey='all')
for count, ax in enumerate(axes.flat):
if count < rank:
# Get the eigenvector
eigenvector = one_eigenvectors[:, count]
# Determine the vector length and calculate n
vector_length = len(eigenvector)
# For an n×n² matrix, we need vector_length = n³
# So n = (vector_length)^(1/3)
n = round(vector_length**(1/3))
# Reshape to n×n² matrix
matrix = eigenvector.reshape(n, n**2)
# Display the matrix
im = ax.imshow(np.around(matrix, decimals=14), interpolation='none')
# Add vertical lines at every n steps
for i in range(1, n):
ax.axvline(x=i*n - 0.5, color='red', linestyle='-', linewidth=1)
ax.set_title(f"Eigenvector {count+1}")
plt.tight_layout()
plt.show()
1.2. Symmetrization of Equivariant Non-linear Representations for Graph Learning¶
- Expressiveness limitation: While powerful, standard GNNs face challenges in distinguishing certain graph structures due to their reliance on local message-passing. This limitation is formalized by the Weisfeiler-Lehman (WL) test, a method for detecting graph isomorphism by iteratively refining node labels based on neighborhood information. Standard GNNs effectively implement a limited version of the WL algorithm, inheriting its inability to distinguish non-isomorphic graphs that the WL test cannot differentiate.
The inability of GNNs to distinguish non-isomorphic graphs is directly tied to the inability to count substructures.
Theorem (Chen et al. 2020): GNNs cannot perform induced-subgraph-count of substructures consisting of 3 or more nodes.
- We will now explores methods to increase expresiveness beyond the Weisfeiler-Lehman (WL) isomorphism test, such as node marking with symmetrization, feature augmentation, substructure-aware models, and subgraph-based architectures.
How do real-world graph theory tools deal with the shortcomings of WL isomorphism test?
Nauty(No AUTomorphisms, Yes?) by Brendan D. McKay is a graph automorphism detection tool that builds upon the WL algorithm with several significant improvements:
Individualization-Refinement Framework: While WL can fail to distinguish certain non-isomorphic graphs, nauty combines color refinement with a technique called "individualization." When the standard refinement reaches a fixed point with multiple nodes having the same color, nauty selectively assigns a unique color to one node (individualization) and continues refinement. This process creates a search tree that systematically explores possible colorings. All branches of the tree must be explored.
Automorphism Pruning: Nauty actively identifies and exploits graph automorphisms (symmetries) during its search. When it discovers an automorphism, it can prune large portions of the search space, dramatically reducing computation time for highly symmetric graphs.
Target Cell Selection: Nauty implements sophisticated heuristics for choosing which cell (group of same-colored vertices) to individualize next, significantly affecting search efficiency.
Node Marking and Symmetrization¶
Breaking and Restoring Symmetry with Node Markings¶
Murphy et al. (2019) introduced a two-stage approach to enhance GNN expressiveness:
- Node Marking: Assign unique identifiers (e.g., one-hot vectors of the node ids) to nodes, breaking permutation symmetry and enabling the GNN to encode global structural relationships.
- Symmetrization: Average model outputs over all possible permutations of $n$ nodes to restore permutation equivariance:
$$ \Gamma(\mathbf{A}) = \frac{1}{n!} \sum_{\pi \in \mathbb{S}_n} \text{GNN}(\mathbf{A}, \pi \circ I_n), $$
where,
- $\mathbb{S}_n$: Symmetric group of node permutations.
- $\pi \circ {\bf A}$: Permuted adjacency matrix.
- $\text{GNN}({\bf A}, {\bf X})$: GNN processing the graph ${\bf A}$ with node features ${\bf X}$.
- The average ensures permutation equivariance of the GNN.
- At first, this may sound strange. Why are we making a GNN permutation-sensitive?
- By first breaking symmetry through marking nodes with unique ids and then symmetrizing over all possible markings, we can capture structural patterns that standard GNNs cannot distinguish.
- This approach allows us to overcome the limitations of the Weisfeiler-Lehman isomorphism test that bounds standard GNN expressivity.
Case Study: CSL Graphs¶
Consider two CSL graphs $G_1$ and $G_2$ with different skip connection patterns. Standard GNNs fail to distinguish them due to identical local neighborhoods.
- The Weisfeiler-Lehman (WL) algorithm, which underlies most GNNs, cannot detect the structural differences between these graphs.
- However, by employing node marking with relational pooling, we can overcome this limitation:
- Node Marking: We select a node (e.g., node 2) and assign it a unique feature vector that distinguishes it from all other nodes
- Message Propagation: Run the WL algorithm or GNN with this marked node
- Structural Differentiation: The marking creates distinct patterns:
- In $G_1$, the WL algorithm assigns unique colors to all nodes after two iterations, reflecting asymmetric global connections.
- In $G_2$, symmetric skip links yield only three distinct colors.
Symmetrization over all marked permutations allows the GNN to detect these differences while maintaining invariance to node orderings.
Feature Augmentation Strategies¶
Deterministic vs. Stochastic Identifier Injection¶
Feature augmentation enhances node representations by incorporating unique identifiers:
- Deterministic Identifiers (Murphy et al., 2019):
For a graph with $n$ nodes, concatenate one-hot node IDs to input features and symmetrize outputs:
$$ \mathbf{h} = \frac{1}{n!} \sum_{\pi \in \mathcal{S}_n} \text{GNN}(\mathbf{A}, \pi \circ I_n), $$ where $\mathbf{h} \in \mathbb{R}^{n\times d}$, where $d \geq 1$ is the dimension of the node embeddings. While theoretically an universal approximation, the $O(n!)$ complexity requires Monte Carlo approximations.
Pros:
- It can be proved that they are universal (Murphy et al, 2019), and thus can approximate every function defined on graphs of any order.
Cons:
- Computationally expensive (but tractable solutions can be obtained by trading off expressive power, exactly as we saw for Janossy Pooling in our set lecture.)
- Random Features (Abboud et al. 2021, Sato et al., 2021):
Assign random $k$-dimensional vectors $$\mathbf{R}_v \in \mathbb{R}^{n \times k}$$ to nodes:
$$ \mathbf{h} = \text{GNN}(\mathbf{A}, \mathbf{R}). $$ Randomness induces stochastic distinguishability, with equivariance achieved in expectation. However, training instability and generalization challenges arise from high-variance gradients.
Pros:
- Same computational complexity as standard GNNs.
- It can be proved that they are universal (Abboud et al, 2021), and thus can approximate every function defined on graphs of any order.
Cons:
- The resulting function (taking as input ${\bf A}$ augmented with random node ids) is invariant to permutations of the vertex ids only in expectation.
- In practice: Unless the support of the random features is small, these are hard to train, hard to converge, and hard to generalize.
Subgraph-Based Neural Networks¶
K-ary representations for graphs¶
$k$-ary representations in Relational Poolling is equivalent to using subgraphs to represent a graph.
Bag-of-Subgraphs Formalism¶
Subgraph GNNs decompose graphs into overlapping subgraphs (e.g., ego networks, random walks) and process each independently:
$$
\mathbf{H} = \text{Pooling}\left(\{\text{GNN}(\mathbf{A}^{(s)}, \mathbf{X}^{(s)})\}_{s=1}^S\right),
$$
where $\mathbf{A}^{(s)}$ and $\mathbf{X}^{(s)}$ denote the adjacency matrix and features of subgraph $s$, and $\text{Pooling}$ is a set function that aggregates results across subgraphs. Variants like Bevilacqua et al. (2022) use policy-guided subgraph selection, trading off expressiveness and $O(n^2)$ complexity.
- Pros:
- More expressive than standard GNNs
- Might be tractable.
- Cons:
- Domain knowledge is required to choose which substructures to count.
Subgraph-based architectures¶
View each graph as a bag of subgraphs, obtained through a deterministic function (which is called subgraph selection policy)
- Reconstruction conjecture: The reconstruction conjecture is a classical open problem in graph theory that states every finite simple graph with at least three vertices can be uniquely determined, up to isomorphism, by its collection of vertex-deleted subgraphs (commonly referred to as its deck).
- In other words, for any two graphs $G$ and $H$ with $|V(G)|,|V(H)| \geq 3$, if every vertex-deleted subgraph of $G$ is isomorphic to a vertex-deleted subgraph of $H$ (and vice versa), then the graphs $G$ and $H$ must be isomorphic. This conjecture, originally proposed by Kelly and Ulam, implies that the entire structure of a graph is encoded in these local fragments, so that even if one removes a single vertex at a time, the remaining pieces collectively contain enough information to reconstruct the original graph. Despite being confirmed for graphs with up to 13 vertices and holding for almost all graphs in a probabilistic sense, the conjecture remains unproven in its general form.
Figure from Cotta et al. 2021.
Employ an architecture (or encoder) returning a node representation, that is invariant to permutation of node ids and invariat to permutations of elements in the bag.
Hence, a valid architecture consists of a GNN applied to each subgraph independently, followed by a set representation that aggregates the results over all subgraphs.
Several variants (Cotta et al., 2021, Zhang and Li, 2021, You et al, 2021, Bevilacqua et al., 2022, Zhao et al., 2022, Papp et al., 2021, Frasca et al. 2022, Quian et al 2022).
- Pros:
- More expressive.
- No domain knowledge is required, assuming domain agnostic subgraph selection policies.
- Cons:
- Computationally expensive for large graphs, where the number of subgraphs might be too large.
Conclusions¶
We have presented GNNs as standard architectures applied to graph data, which guarantee invariance to permutations of node ids.
We have expanded on their limited expressive power, which results, for example, in
- Non-isomorphic graphs getting the same representations,
- Inability to count substructures.
We have introduced several lines of work trying to break this expressivity limit.
We have discussed the limitations of existing more expressive methods, and shown that the expressivity problem is not solved, yet.
References¶
Srinivasan and Ribeiro, 2020. Srinivasan, B., and Ribeiro, B. On the Equivalence between Positional Node Embeddings and Structural Graph Representations. ICLR 2020.
Morris et al., 2019. Morris, C., Ritzert, M., Fey, M., Hamilton, W. L., Lenssen, J. E., Rattan, G., and Grohe, M. Weisfeiler and leman go neural: Higher-order graph neural networks. AAAI 2019
Veličković et al., 2018. Veličković, P., Cucurull, G., Casanova, A., Romero, A., Liò, P., and Bengio, Y. Graph attention Networks. ICLR 2018
Bahdanau et al., 2015. Bahdanau, D., Cho, K. H., and Bengio, Y. Neural machine translation by jointly learning to align and translate. ICLR 2015
Xu et al., 2019. Xu, K., Hu, W., Leskovec, J., and Jegelka, S. How powerful are graph neural networks? ICLR 2019
Murphy et al., 2019. Murphy, R., Srinivasan, B., Rao., V. and Ribeiro, B. Relational Pooling for Graph Representations. ICML 2019
Maron et al., 2019a. Maron, H., Ben-Hamu, H., Shamir, N., and Lipman, Y. Invariant and Equivariant Graph Networks. ICLR 2019
Maron et al., 2019b. Maron, H., Ben-Hamu, H., Segol, N., and Lipman, Y. On the Universality of Invariant Networks. ICML 2019
Maron et al., 2019c. Maron, H., Ben-Hamu, H., Serviansky, H., and Lipman, Y. Provably powerful graph networks. NeurIPS 2019
Geerts, 2020. Geerts, F. The expressive power of kth-order invariant graph networks. ArXiv Preprint
Abboud et al., 2021. Abboud, R., Ceylan, I. I., Grohe, M., and Lukasiewicz, T. The surprising power of graph neural networks with random node initialization. IJCAI-21
Sato et al., 2021. Sato, R., Yamada, M., and Kashima, H. Random features strengthen graph neural networks. SDM 2021
Chen et al., 2020. Chen, Z., Chen, L., Villar, S., Bruna, J. Can Graph Neural Networks Count Substructures? NeurIPS 2020
Bouritsas et al., 2022. Bouritsas, G., Frasca, F., Zafeiriou, S., and Bronstein, M. M. Improving graph neural network expressivity via subgraph isomorphism counting. IEEE Transactions on Pattern Analysis and Machine Intelligence 2022
Bodnar et al., 2021. Bodnar, C., Frasca, F., Otter, N., Wang, Y. G., Liò, P., Montúfar, G., and Bronstein, M. M. Weisfeiler and lehman go cellular: CW networks. NeurIPS 2021
Cotta et al., 2021. Cotta, L., Morris, C., and Ribeiro, B. Reconstruction for powerful graph representations. NeurIPS 2021
Zhang and Li, 2021. Zhang, M. and Li, P. Nested graph neural networks. NeurIPS 2021
You et al., 2021. You, J., Gomes-Selman, J., Ying, R., and Leskovec, J. Identity-aware graph neural networks. AAAI 2021.
Bevilacqua et al., 2022. Bevilacqua, B., Frasca, F., Lim, D., Srinivasan, D., Cai, C., Balamurugan, G., Bronstein, M. M., Maron, H. Equivariant Subgraph Aggregation Networks. ICLR 2022
Zhao et al., 2022. Zhao, L., Jin, W., Akoglu, L., and Shah, N. From stars to subgraphs: Uplifting any GNN with local structure awareness. ICLR 2022.
Papp et al., 2021. Papp, P. A., Martinkus, K., Faber, L., and Wattenhofer, R. Dropgnn: Random dropouts increase the expressiveness of graph neural networks. NeurIPS 2021
Frasca et al., 2022. Frasca, F., Bevilacqua, B., Bronstein, M. M., Maron, H. Understanding and Extending Subgraph GNNs by Rethinking their Symmetries. NeurIPS 2022
Quian et al., 2022. Qian, C., Rattan, G., Geerts, F., Morris, C., Niepert, M. Ordered Subgraph Aggregation Networks. NeurIPS 2022