Enumeration of cospectral and coinvariant graphs

We present enumeration results on the number of connected graphs up to 10 vertices for which there is at least one other graph with the same spectrum (a cospectral mate), or at least one other graph with the same Smith normal form (coinvariant mate) with respect to several matrices associated to a graph. The present data give some indication that possibly the Smith normal form of the distance Laplacian and the signless distance Laplacian matrices could be a finer invariant to distinguish graphs in cases where other algebraic invariants, such as those derived from the spectrum, fail. Finally, we show a new graph characterization using the Smith normal form of the signless distance Laplacian matrix.


Introduction
Spectral graph theory aims to understand to what extent graphs are characterized by their spectra. Starting from the eigenvalues of a matrix associated to a graph, it seeks to deduce combinatorial properties of the graph. For this, we associate a graph G to a matrix M and analyze the eigenvalues of M . These eigenvalues are called the spectrum of G with respect to the matrix M , and its multiset is denoted by M -spectrum(G). M -cospectral graphs are graphs that share M -spectrum. A graph G is determined by its M -spectrum (M -DS for short) if only isomorphic graphs are cospectral with G.
In connection with the graph isomorphism problem, it is of interest what fraction of all graphs is uniquely determined by its spectrum. Haemers con-jectured that the fraction of graphs on n vertices with a M -cospectral mate tends to zero as n tends to infinity. Numerical data for n ≤ 9 was given by Godsil and McKay [17], for n = 10, 11 by Haemers and Spence [19] and for n = 12 by Brouwer and Spence [13]. Aouchiche and Hansen [6] presented a numerical study in which they looked into the spectra of the distance, distance Laplacian and distance signless Laplacian matrices of all the connected graphs on up to 10 vertices. Recently, Pinheiro, Souza and Trevisan [27] provided some numerical evidence that the complementary spectrum of a graph (the complementary spectrum of a graph G is the set of the complementary eigenvalues of the adjacency matrix of G) distinguishes more graphs than other standard graph spectra. However, the authors also showed that it is hard to compute the complementary spectrum.
The question arises whether it is possible to define a matrix M of G in a (not so sensible) way such that every graph becomes M -DS. This is indeed the case, as it was shown in [15,Section 2.5]. However, in this case it is more work to check cospectrality of the matrices than testing isomorphism. If there would be an easily computable matrix M for which every graph becomes M -DS, the graph isomorphism problem would be solved. Hence, when M is one of the commonly used matrices associated to graphs (adjacency, Laplacian, signless Laplacian, normalized Laplacian, distance matrices), one can say that there is not such a matrix M for which all graphs are M -DS, since there exist many examples of non-isomorphic graphs that share the same M -spectrum. This leaves open the possibility of amplifying spectra with the use of more refined representations for obtaining more faithful graph information.
The main goal of this article is to propose a new way of representing a graph using the Smith normal form (SNF) of certain distance matrices. We provide some numerical evidence that this new algebraic graph representation may do a better job in distinguishing graphs. For this we first need to recall some definitions. A matrix M is said to be equivalent to N if there exist unimodular matrices U and V with entries in Z such that M = U N V . The Smith normal form of a integer matrix M , denoted by SNF(M ), is the unique diagonal matrix diag(f 1 , . . . , f r , 0, . . . , 0) equivalent to M such that r = rank(M ) and f i |f j for i < j. The invariant factors (or elementary divisors) of M are the integers in the diagonal of the SNF(M ). If M is an integer symmetric matrix associated to a graph, then we say that two graphs G and H are M -coinvariant if the SNFs of M (G) and M (H), computed over Z, are the same. Conivariant graphs were introduced in [29]. Note that related to the SNF there is the p-rank, i.e., the rank of the matrix considered over the finite field F p , which is the number of invariant factors not divisible by p. We should note that the p-rank has also been used in the literature to distinguish graphs. Just to name a few, the 2-rank was used joint with the spectrum to characterize symplectic graphs over F 2 [25] and was used to distinguish strongly regular graphs with the same parameters as the symplectic graph [1]. Some relevant p-ranks joint with the spectrum was used to characterize distance-regular graphs [26].
In particular, in this work we study if there is a matrix M (say adjacency, Laplacian, signless Laplacian, etc.) whose SNF distinguishes more graphs.
Broadly speaking, the idea is to verify whether the portion of graphs that have a M -coinvariant mate is smaller than the portion of graphs having a M -cospectral mate for a particular matrix M . Cospectrality and coinvariancy both play an important role in the famous graph isomorphism problem. Actually, it is not yet known if testing graph isomorphism is a hard problem or not, whether determining whether two graphs are cospectral or coinvariant can be done in polynomial time [28,21]. It is also known that testing coinvariancy is experimentally faster than testing cospectrality [2]. Thus, one can focus on testing isomorphism among coinvariant graphs.
Our results show that the SNF of the signless distance Laplacian matrix provide a way of representing graphs which does a better job than the spectrum in distinguishing them. The distance Laplacian and the signless distance Laplacian matrices have received quite a lot of attention over the last years [7,8,11,23,16,24]. This article is a sequel to the work by Aouchiche and Hansen [6]. Numerical data on the number of cospectral and coinvariant graphs is given for several matrices, and we also take the opportunity to correct an earlier value. This paper also complements the work by Haemers and Spence [19], Lepovi [22] and Godsil and McKay [18] on enumerating cospectral graphs.
In particular, we extend the computer enumeration for cospectral graphs of [18], [22], [19] and [6] to all connected graphs on at most 10 vertices that have at least a cospectral mate with respect to the distance Laplacian matrix and the signless distance Laplacian matrix. We also enumerate graphs with at most 10 vertices which have a coinvariant mate for several associated matrices. Finally, we present a novel way to show a graph characterization using the SNF of the distance Laplacian and signless distance Laplacian matrix, illustrating the power of this new proposed graph invariant.

Enumeration
In order to make our enumeration results for several matrices comparable with the data obtained for the graph distance matrices, we focus on connected graphs. Denote by G n the set of connected graphs with n vertices. Given a connected graph G, we will study the following associated matrices: the adjacency matrix A(G), the Laplacian matrix L(G), the distance matrix D(G), the signless Laplacian matrix Q(G), the distance Laplacian matrix D L (G) and the signless distance Laplacian matrix D Q (G).
Let G sp n (M ) be the set of graphs in G n which have at least one cospectral mate in G n with respect to an associated matrix M . Table 1 provides the number of cospectral mates of connected graphs with respect to several associated matrices.   Analogously, let G in n (M ) be the set of graphs in G n which have at least one coinvariant mate in G n with respect to an associated matrix M . Table 2 shows the enumeration of G in n (M ) for several associated matrices.  Extensive research has been devoted to understand cospectral graphs, but much less has been dedicated to understand coinvariant mates and its potential to characterize graphs. The reason for this could be that for matrices A, L, Q and D, there is a large proportion of connected graphs having a M -coinvariant mate, as Figure 1 shows. We follow [14] in defining the spectral uncertainty sp n (M ) with respect to M as the ratio |G sp n (M )|/|G n |, and the invariant uncertainty in n (M ) with respect to M as the ratio |G in n (M )|/|G n |.  Figure 1: The fraction of graphs on n vertices that have at least one cospectral mate with respect to a certain associated matrix is denoted as sp. The fraction of graphs on n vertices with respect to a certain associated matrix that have at least one coinvariant mate is denoted as in. Table 3 presents the number of connected graphs having at least one cospectral or at least one coinvariant mate for the distance Laplacian and the signless distance Laplacian matrices. Here, |G sp−in n (M )| denotes the number of graphs with a cospectral mate which is also a coinvariant mate with respect to the corresponding matrix M . Aouchiche and Hansen [6] enumerated cospectral graphs for the distance, distance Laplacian and distance signless Laplacian matrices of all the connected graphs up to 10 vertices. While most of their results are consistent with ours, in Table 3 we obtain 20455 cospectral graphs with 9 vertices with respect to the distance Laplacian matrix, while they reported that there are 19778 of such graphs.   We also include the spectral uncertainty for Q, since according to Table 1, this would be the best invariant for distinguishing graphs using the spectrum.
According to our results, the SNF of D Q performs better than the spectrum for distinguishing graphs for all considered matrices. We should also note that there is no significant improvement when both the spectrum and the SNF are used together, as the parameter G sp−in n (M ) indicates in Table 3, thus this has not been added in Figure 2.  Figure 2: The fraction of graphs on n vertices that have at least one cospectral mate with respect to a certain associated matrix is denoted as sp. The fraction of graphs on n vertices with respect to a certain associated matrix that have at least one coinvariant mate is denoted as in.
In this work we also tested the discrimination power of the p-rank on distinguishing graphs. However, since the p-rank can take values from 0 to n, in general, it seems not such a good graph invariant. Thus we performed an enumeration of graphs with the same SNF for the matrices introduced above over F p with p ∈ 2, 3, 5, 7. We used this since the SNF of a matrix M over F p is a finer invariant than the p-rank. The enumeration results showed a clear tendency to claim that, for any matrix M ∈ {A, L, Q, D, D L , D Q }, almost all graphs on n vertices have another graph with the same SNF of M over F p . Thus, we decided not to include these numerical results on the tables.
Aouchiche and Hansen [6] also explored how to improve the spectral uncertainty by considering two and three matrices together. Analogously as it was done in [6], in Table 4 we show the number of cospectral and coinvariant graphs when two matrices are considered. Let G sp n (M, N ) be the set of graphs in G n which have a cospectral mate in G n with respect to an associated matrices M and N , and let G in n (M, N ) be the set of graphs in G n which have a coinvariant mate in G n with respect to an associated matrices M and N .     Table 4. For the pair (D L , D Q ), we see and advantage in considering the SNF. But for the other pairs, we observe that the spectrum is much better. There is a clear improvement by taking the spectrum of the distance matrix together with the spectrum of either D L or D Q to the same obtained by the SNF. This will also stand in the following analysis.  Figure 3: The fraction of graphs on n vertices that have at least one cospectral mate with respect to a certain associated matrix is denoted as sp. The fraction of graphs on n vertices with respect to a certain associated matrix that have at least one coinvariant mate is denoted as in.
Let |G sp−in n (M, N )| denote the number of graphs with a cospectral mate with respect to the matrix M that is also a coinvariant mate with respect to the matrix N . In Table 5, we compute |G sp−in It is interesting to observe that the combination of the spectrum of D with the SNF of D Q gives better results than using only the spectrum of the two matrices. Therefore, this suggests that when distinguishing graphs, we should compute first the SNF of their signless distance Laplacian matrices and then the spectrum of their distance matrices.   The results from this analysis are shown in Table 6.   To sum up, from the above computational results one can conclude that the best procedure to distinguish graphs using the spectrum and the SNF is first to compute the SNF of their D Q matrices, since in n (D Q ) has the best performance over the spectral and invariant uncertainty of all matrices. Then, if necessary, compute the spectrum of their A matrices, since |G sp−in n (A, D L )| is lower than |G in n (D L , D Q )| for n ≤ 10. Finally compute the SNF of the D L matrices.

Coinvariant trees
We This fact lead the authors to conjecture that every tree is determined by its distance Laplacian spectrum, and by its distance signless Laplacian spectrum. Analogously, for the SNF of D, D L and D Q of trees one can obtain some similar insights. But for that, first we need to state a result by Hou and Woo [20], who extended the Graham and Pollak celebrated formula det(D(T n+1 )) = (−1) n n2 n−1 for any tree T n+1 with n + 1 vertices to the SNF of the distance matrix.
The following is a straight forward consequence from Theorem 1, since this implies that all trees on n vertices have the same SNF of its distance matrix D. After enumerating coinvariant trees with at most 20 vertices with respect to D L and D Q , we found no D L -coinvariant mates and no D Q -coinvariant mates among all trees with up to 20 vertices. This fact lead us to conjecture that almost all trees are determined by the SNF of its distance Laplacian, and analogously, by the SNF of its distance signless Laplacian.

Graphs determined by the SNF
Not much is known regarding graph characterizations using the SNF. A few examples of graphs characterized by the SNF of the adjacency matrix and the Laplacian matrix appear in [5] or [12,Chapter 13.8]. However, our computational results from Section 2 provide an indication that possibly almost no graph has a coinvariant mate when n → ∞ for the distance Laplacian matrix D L and the signless distance Laplacian matrix D Q . While the SNF of D L has been recently used to characterize complete graphs and star graphs [2], to our knowledge there is not yet any graph characterization result using the SNF of D Q . In this section we present a new method to show that complete graphs can be determined by considering the SNF of D Q .
As mentioned before, it is known that complete graphs and star graphs are determined by the SNF of the distance Laplacian matrix [2]: Complete graphs are determined by the SNF of the distance Laplacian matrix. In this section we will show an analogous result to Theorem 3, but instead we will use the SNF of the signless distance Laplacian matrix. In order to do so we need to define the distance ideals of a graph, which were first introduced in [4].
Given a connected graph G = (V, E) and a set of indeterminates X G = {x u : u ∈ V (G)}, let diag(X G ) denote the diagonal matrix with the indeterminates in the diagonal and zeroes elsewhere. The generalized distance matrix D(G, X G ) of G is the matrix with rows and columns indexed by the vertices of G defined as diag(X G ) + D(G). Note that one can recover the distance matrix from the generalized distance matrix by just evaluating X G at the zero vector, that is, D(G) = D(G, 0). One can also recover the distance Laplacian and signless distance Laplacian matrices as follows. Let tr(u) denote the transmission of a vertex u, which is defined as v∈V d G (u, v), and let tr(G) be the vector whose entries are associated with the transmission of the vertices of G. Then, D L (G) = −D(G, −tr(G)) and D Q = D(G, tr(G)).
Let Z[X G ] be the polynomial ring over in the variables X G . For each k ∈ [n] := {1, ..., n}, the k-th distance ideal I k (G, X G ) of G is the determinantal ideal given by where n is the number of vertices of G and minors i (D(G, X G )) is the set of the determinants of the k × k submatrices of D(G, X G ). An alternative way of computing the SNF of a matrix M is as follows. Let ∆ k (M ) denote the greatest common divisor of the k-minors of the matrix M . Then the k-th invariant factor f k is equal to ∆ k (M )/∆ k−1 (M ), where ∆ 0 (M ) = 1. Therefore, evaluating the k-th distance ideal I k (G, X G ) at X G = 0, we obtain the ideal in Z generated by ∆ k (M ), that is, ∆ k (D(G)) ⊆ Z, from which the invariant factors of D(G) can be recovered [4].
The following result shows a relation between the SNF of the distance matrix and the distance ideals.
In this way, distance ideals can be regarded as a generalization of the SNF of the distance, distance Laplacian and signless distance Laplacian matrices. Thus, to recover the SNF of D(G), D L (G) and D Q (G) from the distance ideals, one just needs to evaluate X G at 0, −tr(G) and tr(G), respectively.
In order to show our main result of this section we need the following theorem, which provides the distance ideals of complete graphs. Theorem 6. [4, Theorem 10] The k-th distance ideal of the complete graph K n with n vertices is generated by From Theorem 6 we can recover the SNFs of the distance, distance Laplacian and signless distance Laplacian matrices of the complete graph. By evaluating the distance ideals at x v = 0 for each v ∈ V , we have that ∆ i (D(K n )) = 1, for i ∈ [n − 1], and ∆ n (D(K n )) = (−1) n + n(−1) n−1 = n − 1. From which follows that the SNF of the distance matrix of the complete graph with n vertices is I n−1 ⊕ (n − 1). By evaluating the distance ideals at x v = −n + 1 for each v ∈ V , we obtain the SNF of distance Laplacian matrix of the complete graph with n vertices is 1 ⊕ nI n−2 ⊕ 0. And by evaluating the distance ideals at x v = n − 1 for each v ∈ V , we obtain the SNF of distance Laplacian matrix of the complete graph with n vertices is 1 ⊕ (n − 2)I n−2 ⊕ 2(n − 1)(n − 2).
An ideal is said to be unit or trivial if it is equal to 1 . Note that every graph with at least one non-loop edge has at least one trivial distance ideal. Also if the k-th invariant factor of D(G, d) is not equal to 1, then the ideal I k (D, X D ) is not trivial. Therefore, for any graph G and any d ∈ Z V (G) , the number of invariant factors equal to 1 of the matrix D(G, d) is greater or equal than the number of trivial distance ideals of G. In particular, for any positive integer k, the family of graphs with at most k trivial distance ideals contains the family of graphs with at most k invariant factors of D(G, d) equal to 1.
The last ingredient that we need is the following result. which characterizes graphs with at most one trivial distance ideal.

Theorem 7. [4] A connected graph has only one trivial distance ideal over Z[X]
if and only if G is either a complete graph or a complete bipartite graph.
Therefore, if G is a connected graph such that its signless distance Laplacian matrix has at most one invariant factor equal to 1, then G is a complete graph or a complete bipartite graph. We have already seen that the SNF of D Q (K n ) is 1 ⊕ (n − 2)I n−2 ⊕ 2(n − 1)(n − 2). From which follows that complete graphs with at least 4 vertices have one invariant factor of SNF of D Q equal to one. Next we prove that these graphs are the only graphs whose signless distance Laplacian matrix have one invariant factor equal to 1.
Theorem 8. Let G be a connected graph. The SNF of D Q (G) has at most one invariant factor equal to 1 if and only if G is a complete graph with n = 3 vertices.
Proof. It only remains to verify that the second invariant factor of complete bipartite graphs is equal to one. In [4,Theorem 23], the second distance ideal of complete bipartite graphs were computed. Let D(K m,n , {x 1 , . . . , x m , y 1 , . . . , y n }) be the generalized distance matrix of K m,n , which is equal to the following matrix diag(x 1 , . . . , x m ) − 2I m + 2J m J m,n J n,m diag(y 1 , . . . , y n ) − 2I n + 2J n .
Now we are ready to state the main result of this section.
Corollary 9. Complete graphs are determined by the SNF of the signless distance Laplacian matrix.
It would be interesting to obtain a characterization of graphs whose SNF of D L and D Q has two invariant factors equal to 1. This could be obtained after showing a characterization of graphs having two trivial distance ideals. However, the latter problem seems to be difficult, since there exist infinitely many minimal induced forbidden graphs [3] (most of them are the same needed in the characterization of the well-known Strong Perfect Graph Theorem).

Concluding remarks
While the adjacency, Laplacian and signless Laplacian matrices have attracted a lot of attention in the field of spectral characterizations of graphs, for such matrices, the SNF does not seem useful to distinguish graphs, since almost all graphs on 10 vertices have a coinvariant mate. However, our enumeration results suggest that the SNF of the distance Laplacian and the signless distance Laplacian matrices could be a finer invariant to distinguish graphs in cases where other algebraic invariants, such as those derived from the spectrum, fail. This confirms what was suggested by Biggs [10]. Another argument to consider the SNF as a graph parameter to distinguish graphs is that this is a finer invariant than the p-rank: the p-rank is just the number of invariant factors not divisible by p.
In this work we show that the results by Aouchiche and Hansen [6] can be pushed further. In particular, we provide numerical evidence that using the invariant factors of the SNF of certain distance matrices one can improve some of the results by Aouchiche and Hansen. In this regard, our computational results suggest that possibly almost no graph has a coinvariant mate when n → ∞ for the matrices D L and D Q .