canonical.permutation(graph, sh="fm")
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:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
See the paper in references for details about these.
permute.vertices
to apply a permutation to a
graph, graph.isomorphic
for deciding graph isomorphism,
possibly based on canonical labels.## Calculate the canonical form of a random graph
g1 <- erdos.renyi.game(10, 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)))
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)
Run the code above in your browser using DataLab