# What is the canonical label?

Data MiningDatabaseData Structure

Best Seller

89 Lectures 11.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

#### Data Science and Data Analysis with Python

50 Lectures 3.5 hours

A standard method for handling the graph isomorphism issues is to map each graph into a specific string representation called its code or canonical label. A canonical label has the property that if two graphs are isomorphic, therefore their codes should be equal.

This property enables us to test for graph isomorphism by analyzing the canonical labels of the graphs. The first phase toward building the canonical label of a graph is to discover an adjacency matrix description for the graph. It shows an instance of such a matrix for the given graph.

A graph can have higher than one adjacency matrix description because there are several methods to order the vertices in the adjacency matrix. The first row and column correlate to the vertex a that has 3 edges, the second row and column correlate to another vertex a that has 2 edges, etc. It can change derive all the adjacency matrix descriptions for a graph, it is required to be treated all possible permutations of rows of the matrix.

Example − Consider the following matrix

M = 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

The following permutation matrix can be used to transform the first row (and column) with the third row of M −

P13 =  0 0 1 0
0 1 0 0
1 0 0 0
0 0 0 1

where P13 is acquired by exchanging the first and third row of the identity matrix. It can exchange the first and third rows (and columns), the permutation matrix is multiplied with M −

M′ = P13T X M X P13= 11 10 9 12
7  6 5  8
3  2 1  4
15 14 13 16

The second step is to decide the string description for each adjacency matrix. Because the adjacency matrix is symmetric, it is efficient to produce the string description depending on the upper triangular part of the matrix.

The code is acquired by linking the entries of the upper triangular matrix in a columnwise fashion. The last step is to correlate all the string descriptions of the graph and select the one that has the lowest (or highest) lexicographic value.

The previous approach appear costly because it needed us to determine all possible adjacency matrices of a graph and to evaluate each of their string descriptions to discover the canonical label. Furthermore, there are kl permutations that should be treated for each graph that includes k vertices.

There are various methods developed to lower the complexity of this task contain caching the previously computed canonical label and decreasing the number of permutations required to decide the canonical label by incorporating more data including vertex labels and the degree of a vertex.

Updated on 11-Feb-2022 13:45:01