2025-02-24 graphs lecture 10

[[lecture-data]]
Summary

last time

Today

Much of the content from today from
"How Powerful are GNNs" by Xu et al 2019 - created this architecture

1. Graph Signals and Graph Signal Processing

Recall from last class that we discussed the Weisfeiler-Leman Graph Isomorphism Test, which uses the

Color refinement algorithm

The color refinement algorithm is an algorithm to assign colorings to nodes.

Algorithm

Given graph G=(V,E) with node features x

let ci(0)=f(,{xi})iV (assign colors based on node feature values)
let t=0

while True:

  1. let ci(t)=f(ci(t1),{{cj(t1),jN(i)}})iV
  • assign colors based on previously assigned colors
  1. if ci(t)==ci(t1)i, break. else, t=t+1

Here, f is a hash function that assigns colors.

Today, we will finish up the example that we began last class.

Example

2025-02-19-graph-2.png

Color refinement for G1

No node features, so assume all 1. First, Assign colors based on node features.

step t=0:
c1(0)=c2(0)=c3(0)=f(,1)=k1

step t=1:
c1(1)=f(k1,{k1})=k1c3(1)=f(k1,{k1})=k1c2(1)=f(k1,{k1,k1})=k2
Evaluate: did the colors change?

  • Yes: continue!

step t=2:
c1(2)=f(k1,{k1})=k1c3(2)=f(k1,{k1})=k1c2(2)=f(k2,{k1,k1})=k2
Evaluate: did the colors change?

  • No - so we are done!
  • This is the final coloring.

return {k1,k1,k2}

Color refinement for G2

Again, there are no node features, so we assume the signals are all 1.

step t=0: assign colors based on node features:
c1(0)=c2(0)=c3(0)=f(,1)=k1
step t=1:
c1(1)=c2(1)=c3(1)=f(,{k1,k1})=k1

evaluate: did the colors change?

  • No - so we are done
  • This is the final coloring

return {k1,k1,k1}

Since the outputs of the algorithm are different, we can conclude that G1 and G2 are not isomorphic.

Note

There are other better algorithms that perform similar tests, but they often come at the expense of more computations

Today, we want to know: Are GNNs as powerful as the Weisfeiler-Leman Graph Isomorphism Test?

Proposition

If a GNN can distinguish between graphs G1 and G2, then so can the WL test.

Proof

Consider the AGGREGATE-COMBINE representation of GNNs (recall graph SAGE for something similar) where each layer consists of

  1. aggregation step on the neighborhood of each node
a,i=AGGREGATE({(x1)u:uN(i)})
  1. combine step
(x)i=COMBINE(a,i,(x1)i)

And with a permutation invariant readout layer

XG=READOUT({(x)i:iV})

(these are typically like the mean, max, sum, etc)

Suppose after iterations in the WL test and layers as described above,

  1. the embeddings XG1XG2
  2. the WL test cannot decide if G1 and G2 are non-isomorphic

If the WL test cannot decide, then every previous iteration j=0,1,, in the test, then

  • G1 and G2 must have the same color multisets, call them {(cj)v}, and
  • the color neighborhoods {(cj)u:uN(v)} are also the same for all v

NTS that if WL test for vG1 and vG2 gives the same color, then the GNN gives the same embedding.

want to show ()

if the WL test gives (cj)v=(cj)v for all v,v, then the GNN always produces (xj)v=(xj)v

Since there are no node features, impute 1 as the feature for all nodes in each graph.

  • The color refinement algorithm will assign the same colors to all nodes at the initial step as we saw in the example
  • The 0th layer of the GNN assigns (x0)v=(x0)v for all v,v since all feature values are the same

Induction Hypothesis
Suppose () holds for iteration/layer j.

  • the WL test outputs the same colors (cj+1)v and (cj+1)v for all v,v. That is,
[(cj)v,{(cj)u|uN(v)}]=[(cj)v,{(cj)u:uN(v)}]
  • By the induction hypothesis, we have that
[(xj)v,{[xj]u:uN(v)}]=[(xj)v,{[xj]u:uN(v)}]

Since the same AGGREGATE and COMBINE functions are applied to both graphs, then we automatically get that

(xj+1)v=(xj+1)vv,v

Thus, by induction, if the colors (cj)v=(cj)v for all v,v, the the embeddings (xj)v=(xj)v at any j.

Note

This creates a valid map (xj)v=g((cj)v) for all v between the embeddings of the nodes and the coloring assignment.

We can extend this mapping to include the multiset of embeddings/colors of the neighbors as well, and say that the multiset of all embeddings and neigeborhood embedding pairs also has a map

{(xj)v,{(xj)u:uN(v)}}={g((cj)v),{g((cj)u):uN(v)}}

And these are each the same for the two graphs.

Thus, the (xj)v and (xj)v are the same for all j. And, due to the permutation invariance of the readout layer as defined above, we must have XG1=XG2.

we assumed that the embeddings were NOT equal! Thus, it must be the case that the WL test CAN decide if G1 and G2 are non-isomorphic.

see the WL test is at least as powerful as a GNN for detecting graph non-isomorphism

What have we shown here?

We want to know if GNNs are at least as powerful as the WL test. ie
if the WL test tells G1 and G2 apart, does there exist a GNN that can tell G1 and G2 apart?

ie, are GNNs as powerful as the WL test at telling non-isomorphic graphs apart?

Example

2025-02-24-graph.png
Can a GCN tell these apart? Recall

Graph Convolutional Networks

Introduced by Kipf and Willing, 2017, a graph convolutional network layer is given by
(x)i=σ[jN(i)(x1)j|N(i)|H]
Note that H are row vectors. We can think of each layer as a "degree normalized aggregation"

In AGGREGATE-COMBINE form, a GCN layer is given by

(xj)v=ReLU(W,mean{(xj1)u:uN(v){}})

WLOG, assume W=1. The first layer with readout gives us
2025-02-24-graph-1.png
But then we get the same output for every layer and this GNN fails for permutation invariant readouts.

Takeaway

By the example above, we can see easily that not every GNN is as powerful as the WL test. However, there are some GNNs that can do better, and which can be at least as powerful.

Exercise

Check if graph SAGE with the max aggregation:

(xj)v=max({ReLU(W.(xj)u),uN(v)})

Can tell these graphs apart.

In the example above, where did things break?
2025-02-24-graph-2.png|100 left lp Pros: GCNs and any permutation equivariant GNN does not distinguish between nodes 1 and 3. This is an implicit data augmentation mechanism!
Cons: The GCN cannot distinguish between (1 and 3) and 2, but the structure at 1 or 3 is different from at node 2.

Let's define the computational graph

computational graph

The computational graph tracks the communications that each node makes at each layer or iteration of an algorithm/network.

Example

2025-02-24-graph-3.png
Since 1 and 3 are symmetric, their computational graph is symmetric

Note

L=2 is sufficient because the diameter (or the longest shortest path between two nodes) is of length 2.

see computational graph

We can imagine that we are mapping computational graphs to some embedding space. The issue with the GCN is that it is mapping all three computational graphs to a single embedding space.
2025-02-24-graph-4.png

We need functions/embeddings/maps that are injective. ie, which map different computational graphs (or different multisets of embeddings) to different values in embedding space.

Theorem

Let G1 and G2 be two graphs that the Weisfeiler-Leman Graph Isomorphism Test determines are non-isomorphic. A GNN Φ maps G1 and G2 to Φ(G1)Φ(G2) if the following hold:

  1. Φ aggregates and updates as
(x)v=ϕ((x1)v,φ({(x1)u:uN(v)}))

Where ϕ,φ are injective.

  1. The readout function is (permutation invariant) and injective.
Proof (sketch)

In the proof showing that the WL test is at least as powerful as a GNN for detecting graph non-isomorphism, we showed that if the color refinement algorithm gives (cj)v=(cj)vv,v, then the embeddings (xj)v=(xj)vv,v and that that there is a valid map

(xj)v=g((cj)v)v

We need g to be injective. Why? We don't want it to be the case that there are different colors cv,cw that map to the same embedding xv.

Let f be the hash function in the WL test. Recall that is is bijective for color multisets. We can write the embedding at layer j as follows:

(xj)v=g(f[(cj1)v,{(cj1)u:uN(v)}])(xj)v=g(f[g1((xj1)v),{g1((xj1)u):uN(v)}])ϕ(,φ())the GNN

So to have g injective, we need the GNN to be injective. Thus,

ϕ,φ the GNN is injective g is invective the GNN is as powerful as the WL test

see injective GNNs are as powerful as the WL test