color refinement algorithm

[[concept]]
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.

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}

Mentions

File
Weisfeiler-Leman Graph Isomorphism Test
injective GNNs are as powerful as the WL test
the WL test is at least as powerful as a GNN for detecting graph non-isomorphism
2025-02-19 graphs lecture 9
2025-02-24 graphs lecture 10
2025-03-03 graphs lecture 11