Colour refinement algorithm
In graph theory and theoretical computer science, the colour refinement algorithm also known as the naive vertex classification, or the 1-dimensional version of the Weisfeiler-Leman algorithm, is a routine used for testing whether two graphs are isomorphic. While it solves graph isomorphism on almost all graphs, there are graphs such as all regular graphs that cannot be distinguished using colour refinement.
01History
The first appearance of color refinement is in Stephen H. Unger's program GIT for graph isomorphism, where it is called the Extend method. It was described again, immediately after, in a chemistry paper.
02Description
The algorithm takes as an input a graph with
vertices. It proceeds in iterations and in each iteration produces a new colouring of the vertices. Formally a "colouring" is a function from the vertices of this graph into some set (of "colours"). In each iteration, we define a sequence of vertex colourings
as follows:
is the initial colouring. If the graph is unlabelled, the initial colouring assigns a trivial colour
to each vertex
. If the graph is labelled,
is the label of vertex
.
- For all vertices
, we set
.
In other words, the new colour of the vertex is the pair formed from the previous colour and the multiset of the colours of its neighbours.
This algorithm keeps refining the current colouring. At some point it stabilises, i.e.,
if and only if
. This final colouring is called the stable colouring.
03Graph Isomorphism
Colour refinement can be used as a subroutine for an important computational problem: graph isomorphism. In this problem we have as input two graphs and our task is to determine whether they are isomorphic. Informally, this means that the two graphs are the same up to relabelling of vertices.
To test if and
are isomorphic we could try the following. Run colour refinement on both graphs. If the stable colourings produced are different we know that the two graphs are not isomorphic. However, it could be that the same stable colouring is produced despite the two graphs not being isomorphic; see below.
04Complexity
It is easy to see that if colour refinement is given a vertex graph as input, a stable colouring is produced after at most
iterations. Conversely, there exist graphs where this bound is realised. This leads to a
implementation where
is the number of vertices and
the number of edges. This complexity has been proven to be optimal under reasonable assumptions.
05Expressivity
We say that two graphs and
are distinguished by colour refinement if the algorithm yields a different output on
as on
. There are simple examples of graphs that are not distinguished by colour refinement. For example, it does not distinguish a cycle of length 6 from a pair of triangles (example V.1 in ). Despite this, the algorithm is very powerful in that a random graph will be identified by the algorithm asymptotically almost surely. Even stronger, it has been shown that as
increases, the proportion of graphs that are not identified by colour refinement decreases exponentially in order
.
06Equivalent Characterizations
For two graphs and
with the same number of vertices, the following conditions are equivalent:
and
are indistinguishable by colour refinement.
- The minimum fibration bases of
and
are isomorphic.
and
are fractionally isomorphic.
and
have a common coarsest equitable partition.
and
have the same universal cover.
- For all trees
, there are an equal number of homomorphisms from
to
as there are from
to
.
and
cannot be distinguished by the two variable fragment of first order logic with counting.
- Any message passing graph neural network will map
and
to the same output, if the input node features are the initial colours
.
- Any synchronous anonymous algorithm with broadcast/mailbox message passing in which the input depends on the color only will generate an output that depends, again, on the initial color only.
Sources and credits
This article is adapted from the Wikipedia article “Colour refinement algorithm”, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.
Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.