Canonical permutation of a graph

The canonical permutation brings every isomorphic graphs into the same (labeled) graphs.

canonical.permutation(graph, sh="fm")
The input graph, treated as undirected.
Type of the heuristics to use for the BLISS algorithm. See details for possible values.

canonical.permutation computes a permutation which brings the graph into canonical form, as defined by the BLISS algorithm. All isomorphic graphs have the same canonical form.

See the paper below for the details about BLISS. This and more information is available at

The possible values for the sh argument are:

  • f
{First non-singleton cell.} fl{First largest non-singleton cell.} fs{First smallest non-singleton cell.} fm{First maximally non-trivially connectec non-singleton cell.} flm{Largest maximally non-trivially connected non-singleton cell.} fsm{Smallest maximally non-trivially connected non-singleton cell.}


  • A list with the following members:
  • labelingThe canonical parmutation which takes the input graph into canonical form. A numeric vector, the first element is the new label of vertex 0, the second element for vertex 1, etc.
  • infoSome information about the BLISS computation. A named list with the following members:
    • nof\_nodes
    {The number of nodes in the search tree.} nof_leaf_nodes{The number of leaf nodes in the search tree.} nof_bad_nodes{Number of bad nodes.} nof_canupdates{Number of canrep updates.} max_level{Maximum level.} group_size{The size of the automorphism group of the input graph, as a string. This number is exact if igraph was compiled with the GMP library, and approximate otherwise.}


  • Canonical permutation


Tommi Junttila and Petteri Kaski: Engineering an Efficient Canonical Labeling Tool for Large and Sparse Graphs, Proceedings of the Ninth Workshop on Algorithm Engineering and Experiments and the Fourth Workshop on Analytic Algorithms and Combinatorics. 2007.

See Also

permute.vertices to apply a permutation to a graph, graph.isomorphic for deciding graph isomorphism, possibly based on canonical labels.

  • canonical.permutation
## Calculate the canonical form of a random graph
g1 <-, 20, type="gnm")
cp1 <- canonical.permutation(g1)
cf1 <- permute.vertices(g1, cp1$labeling)

## Do the same with a random permutation of it
g2 <- permute.vertices(g1, sample(vcount(g1))-1)
cp2 <- canonical.permutation(g2)
cf2 <- permute.vertices(g2, cp2$labeling)

## Check that they are the same
el1 <- get.edgelist(cf1)
el2 <- get.edgelist(cf2)
el1 <- el1[ order(el1[,1], el1[,2]), ]
el2 <- el2[ order(el2[,1], el2[,2]), ]
all(el1 == el2)
Documentation reproduced from package igraph, version 0.5.5-3, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.