Exponentially many graphs are determined by their spectrum

As a discrete analogue of Kac's celebrated question on"hearing the shape of a drum", and towards a practical graph isomorphism test, it is of interest to understand which graphs are determined up to isomorphism by their spectrum (of their adjacency matrix). A striking conjecture in this area, due to van Dam and Haemers, is that"almost all graphs are determined by their spectrum", meaning that the fraction of unlabelled $n$-vertex graphs which are determined by their spectrum converges to $1$ as $n\to\infty$. In this paper we make a step towards this conjecture, showing that there are exponentially many $n$-vertex graphs which are determined by their spectrum. This improves on previous bounds (of shape $e^{c\sqrt{n}}$), and appears to be the limit of"purely combinatorial"techniques. We also propose a number of further directions of research.


Introduction
A classical question, popularised in 1966 by Kac [26], is whether one can "hear the shape of a drum": if we know the "spectrum" of a planar domain D ⊆ R 2 (formally, the eigenfrequencies of the wave equation on D, with Dirichlet boundary conditions), is this enough information to reconstruct D up to isometry?Famously (and perhaps surprisingly), this answer to this question is "no": in 1992, Gordon, Webb and Wolpert [17] managed to construct two different "drums" with the same spectrum.
A much shorter version of this story also took place in graph theory.In 1956, in a paper studying connections between graph theory and chemistry, Günthard and Primas [18] asked whether one can reconstruct a graph up to isomorphism given the eigenvalues of its adjacency matrix 1 .Due to the discrete nature of this question, the search for counterexamples is much easier than for Kac's question: only one year later, Collatz and Sinogowitz [8] exhibited a pair of graphs with the same spectrum.This has some rather important practical consequences: if it were the case that all graphs were determined by their spectrum, this would give rise to a very simple graph isomorphism test.It is an open problem to find a provably efficient graph isomorphism test, and spectral information is often used to distinguish graphs in practice.
A striking conjecture due to van Dam and Haemers [19,33,34] (also suggested somewhat later and seemingly independently by Vu [35]) is that graphs which cannot be uniquely identified by their spectrum are extremely rare, in the following natural asymptotic sense.
Definition 1.1.The spectrum of a graph is the multiset of eigenvalues of its adjacency matrix.A graph G is determined by its spectrum (DS for short) if there is no other graph (non-isomorphic to G) which has the same spectrum as G.
Conjecture 1.2.The fraction of unlabelled n-vertex graphs which are determined by their spectrum converges to 1 as n → ∞.Equivalently 2 , the number of (unlabelled) n-vertex graphs determined by their spectrum is 2 n(n−1)/2 n! .
Remark 1.3.To elaborate on the attribution here: for a very long time, it has been an important question in spectral graph theory to understand the asymptotic proportion of graphs which are DS (for example, Schwenk [30] conjectured the opposite of Conjecture 1.2 in 1973, and Godsil and McKay [15] described this general question as "one of the outstanding unsolved problems in the theory of graph spectra").The possibility that Conjecture 1.2 might hold (supported by mounting computational evidence) was first suggested by van Dam and Haemers [33] in 2003 (also later in [34]), though they did not explicitly Matthew Kwan was supported by ERC Starting Grant "RANDSTRUCT" No. 101076777. 1The adjacency matrix of a (simple) graph G, with vertices v 1 , . . ., vn, is the zero-one matrix A(G) ∈ {0, 1} n×n whose (i, j)-entry is 1 if and only if G has an edge between v i and v j . 2 The number of labelled graphs on a particular set of n vertices is 2 n(n−1)/2 , and it is well-known (see for example [16,Lemma 2.3.2]) that all but a vanishingly small fraction of these have a trivial automorphism group.make a conjecture.It seems that Conjecture 1.2 first appeared explicitly in a paper of Haemers [19].
Vu seems to have arrived at Conjecture 1.2 via quite a different pathway: in [35] he presents it as a graph-theoretic variant of a similar conjecture in random matrix theory.We also remark that Garijo, Goodall and Nešetřil [14] and Noy [28] situated Conjecture 1.2 in (different) general frameworks which include a number of other questions about reconstructing graphs from various types of information.
Conjecture 1.2 is rather bold, on account of the fact that there are very few known examples of DS graphs.Indeed, to show that a graph G is DS (without exhaustively computing the spectra of all other graphs on the same number of vertices), it seems necessary to somehow translate information about the spectrum of G into information about the combinatorial structure of G. Spectral graph theory has a number of different tools along these lines, but all of them are rather crude, and essentially all known examples of DS graphs have very special structure.(For example, to prove that complete graphs are DS, one uses the fact that the n-vertex complete graph is the only n-vertex graph with exactly n 2 edges).To the best of our knowledge, the best lower bounds on the number of DS graphs are all of the form e c √ n for some constant c > 0. Such a bound was first observed by van Dam and Haemers [33,Proposition 6], who proved that G is DS whenever every connected component of G is a complete subgraph (the number of graphs of this form is precisely the number of integer partitions of n, which is approximately e c √ n for c = π 2/3 by the Hardy-Ramanujan theorem [23]).Several other families of graphs, similarly enumerated by integer partitions, have since been discovered (see for example [32,38]).On the other hand, there has been much more progress in the opposite direction to Conjecture 1.2, proving lower bounds on the number of graphs which are not DS.For example, a famous result of Schwenk [30] says that only a vanishingly small fraction of trees are DS (meaning that almost all of the exponentially many unlabelled n-vertex trees are non-DS), and, using an operation that is now known as Godsil-McKay switching, Godsil and McKay [15] (see also [20]) proved that the number of n-vertex graphs which are not DS is at least In this paper we prove the first exponential lower bound on the number of DS graphs, finally breaking the "e c √ n barrier" (and thereby answering a question of van Dam and Haemers [33]).
Theorem 1.4.The number of (unlabelled) n-vertex graphs determined by their spectrum is at least e cn for some constant c > 0.
Remark 1.5.Our proof shows that we can take c = 0.01 for large n, but we made no serious attempt to optimise this.
We will outline our proof strategy in Section 2, but to give a quick impression: we consider an explicit family of "nice graphs", each consisting of a long cycle with leaves attached in various carefully-chosen ways.Then, we consider a family of n-vertex graphs Q n obtained by combining complete graphs with line graphs3 of nice graphs, in such a way that certain inequalities and number-theoretic properties are satisfied.We then prove that there are exponentially many graphs in Q n , and that all graphs in Q n are determined by their spectrum.We remark that there is an essential tension in the choice of Q n : in order to prove a strong lower bound we would like our families of graphs to be as "rich" as possible, containing graphs with a wide variety of structure, but in order to reconstruct a graph using the limited information that is (legibly) available in its spectrum, we can only work with graphs with very special structure.
1.1.Further directions.It seems that significant new ideas would be required to go beyond the exponential bound in Theorem 1.4.Indeed, if we consider all the known combinatorial parameters that can be extracted from the spectrum of an n-vertex graph, then we end up with a list of about 2n integers (most notably, the first n spectral moments describe the number of closed walks of each length, and the n non-leading coefficients of the characteristic polynomial can be interpreted as certain weighted sums of subgraph counts).In order to use this combinatorial information to reconstruct say exp(n 1+ε ) different graphs, we would need to use a huge amount of information from each of the integers in our list: roughly speaking, the variation in each integer must correspond to about exp(n ε ) different graphs.It is hard to imagine a natural combinatorial argument that could reconstruct so many different graphs from a single integer of information.
Instead, it seems that non-constructive methods may be necessary in order to prove Conjecture 1.2, or even to make much progress beyond Theorem 1.4.Is there some algebraic criterion which describes whether a graph is DS, without necessarily providing a combinatorial procedure to reconstruct the graph4 ?Can one somehow show that the DS property is "generic" without describing which graphs are DS?
We would also like to propose a number of other questions related to Conjecture 1.2.
• Consider two different n-vertex graphs G, G ′ , chosen uniformly at random, and let Q n be the probability that G and G ′ have the same spectrum.How large is this probability?It seems one can obtain an exponential upper bound for some c > 0, using powerful techniques in random matrix theory (see [7]).
• Conjecture 1.2 is equivalent to the statement that among all n-vertex graphs, there are What lower bounds can we prove on the number of different spectra realisable by n-vertex graphs?There are several different ways to prove an exponential lower bound: in particular, such a bound follows from Theorem 1.4, from the above bound Q n ≤ e −cn , or from results on the range of possible determinants of n × n binary matrices (see [31]).
• Although it is known [30] that almost all trees are not DS, it would still be interesting to prove lower bounds on the number of DS trees.Could it be that there are exponentially many?
• In the continuous setting ("hearing the shape of a drum"), the spectral rigidity conjecture of Sarnak (see [29]) suggests that despite the fact that there are drums with the same spectrum, such drums are always "isolated" from each other: for any drum, making a sufficiently small change to the shape of the drum always changes its spectrum.One can also ask similar questions for graphs.For example, as a weakening of Conjecture 1.2, we conjecture that for a (1 − o(1))fraction of labelled graphs on n vertices, any nontrivial addition/deletion of at most (1/2 − ε)n edges (for any constant ε > 0) results in a graph with a different spectrum.If this were true it would be best-possible: for almost all n-vertex graphs G, one can exchange the roles of two vertices by adding and removing about n/2 edges (obtaining a graph which is isomorphic to G and therefore has the same spectrum).
• Apart from the adjacency matrix, there are several other matrices which can be associated with a graph.Perhaps the best-known examples are the Laplacian matrix and the signless Laplacian matrix (which are both actually used in this paper; see Definition 2.1).Such matrices give us different notions of graph spectra, with which we can ask variations on all the questions discussed so far.Actually, the Laplacian analogue of Theorem 1.4 has already been proved, taking advantage of the fact that the Laplacian spectrum is much better-behaved with respect to complements: Hammer and Kelmans [21] showed that all 2 n of the threshold graphs on n vertices (i.e., all n-vertex graphs which can be constructed from the empty graph by iteratively adding isolated vertices and taking complements) are determined by their Laplacian spectrum.
In the course of proving Theorem 1.4, we actually end up giving new proofs of the analogous result for Laplacian and signless Laplacian spectra.It is still open (and not obviously easier or harder than for the adjacency spectrum) to prove better-than-exponential lower bounds on the number of n-vertex graphs determined by their Laplacian or signless Laplacian spectrum.

Proof overview
We start by defining the Laplacian matrix and the signless Laplacian matrix, two variations on the adjacency matrix.Definition 2.1.Consider a (simple) graph G with vertices v 1 , . . ., v n .Let D(G) be the diagonal matrix whose (i, i)-entry is the degree of v i , and recall the adjacency matrix A(G) of G.
• The Laplacian matrix is defined as L(G) = D(G) − A(G).
• The signless Laplacian matrix is defined as We sometimes refer to the spectra of A(G), L(G) and |L(G)| as the adjacency spectrum, Laplacian spectrum and signless Laplacian spectrum of G, respectively.We say that a graph G is determined by its Laplacian spectrum (respectively, determined by its signless Laplacian spectrum) if there is no other graph (non-isomorphic to G) which has the same Laplacian spectrum (respectively, signless Laplacian spectrum) as G.
While the adjacency matrix is the simplest and most natural way to associate a matrix to a graph, all three of the above notions of spectrum contain slightly different information about G, which can be useful for different purposes.For this paper, the crucial fact about the Laplacian spectrum is that it determines the number of spanning trees of a graph, via Kirchhoff's celebrated matrix-tree theorem (Theorem 3.13).In particular, the Laplacian spectrum tells us whether a graph is connected or not.
Fortunately, there are some connections between the above three notions of spectrum, which we will heavily rely on in this paper.For example, two simple observations are that: • if a graph is bipartite, then its signless Laplacian spectrum is the same as its Laplacian spectrum (Fact 3.1); • if two graphs have the same signless Laplacian spectrum, then their line graphs have the same adjacency spectrum (Proposition 3.15).
Unfortunately, there are some limitations to these connections.In general, neither the Laplacian spectrum nor the signless Laplacian spectrum of a graph contain enough information to actually determine whether the graph is bipartite (and it is not true that for a bipartite graph to be determined by its Laplacian spectrum is the same as for it to be determined by its signless Laplacian spectrum).Also, if a graph Q has the same adjacency spectrum as the line graph of some graph G, it does not necessarily follow that Q is the line graph of some graph with the same signless Laplacian spectrum as G (it does not even follow that Q is a line graph at all, though a deep structure theorem of Cameron, Goethals, Seidel and Shult [6], building on a previous slightly weaker theorem of Hoffman [25], shows that every connected graph which has the same adjacency spectrum as a line graph must be a so-called generalised line graph, with finitely many exceptions).Despite these limitations, in our proof of Theorem 1.4 it is nonetheless extremely useful to move between the three different notions of graph spectra.Roughly speaking, our proof of Theorem 1.4 can be broken down into three parts.First, we describe an explicit family of graphs ("nice graphs"), and prove that they are determined by their Laplacian spectrum (making crucial use of the matrix-tree theorem).Second, we prove that any graph which has the same signless Laplacian spectrum as a bipartite nice graph must be bipartite (from which we can deduce that in fact every bipartite nice graph is determined by its signless Laplacian spectrum).Finally, we define a family Q n of exponentially many n-vertex graphs (which are essentially line graphs of bipartite nice graphs, with some small adjustments for numbertheoretic reasons), and use the Cameron-Goethals-Seidel-Shult theorem to show that if a graph has the same adjacency spectrum as a graph in Q n , then both graphs must have been constructed from line graphs with the same signless Laplacian spectrum.Putting everything together, we see that all of the exponentially many graphs in Q n are determined by their adjacency spectrum.
We next outline each of the above three parts of the proof of Theorem 1.4 in more detail.
2.1.Nice graphs and the Laplacian spectrum.First, we define nice graphs and outline how to prove that they are determined by their Laplacian spectrum.
Definition 2.2.Say that a graph is sun-like5 if it is connected, and deleting all degree-1 vertices yields a cycle.Equivalently, a sun-like graph can be constructed by taking a cycle C, and attaching some leaves to some vertices of C. If a vertex of C has i leaves attached to it (equivalently, if the vertex has degree i + 2), we call it an i-hub.We simply call a vertex a hub if it is an i-hub for some i ≥ 1 (equivalently, if its degree is at least 3).For (integer) parameters k ≥ 1 and ℓ ≥ max(12k, 15), say that a graph G is (ℓ, k)-nice if: • G is a sun-like graph; • the unique cycle C in G has length ℓ; • there are exactly k + 1 hubs, one of which is a 1-hub and the others of which are 2-hubs; • we can fix an orientation of C such that the following holds.Imagine starting at the 1-hub and walking clockwise around C. We should meet our first 2-hub after walking a distance of 4.Then, the second 2-hub should appear at distance 4 or 6 after the first.The third 2-hub should appear at distance 4 or 6 after the second, the fourth should appear at distance 4 or 6 after the third, and so on.(This freedom between 4 and 6 at each step is crucial; it ensures that there are many different nice graphs).
See Figure 1 for an illustration of a (46, 3)-nice graph.We simply say that a graph is nice if it is (ℓ, k)nice for some k, ℓ (satisfying k ≥ 1 and ℓ ≥ max(12k, 15)).We remark that the restriction ℓ ≥ 12k is to ensure that all 2-hubs are closer to the 1-hub in the clockwise direction than the counterclockwise direction.
Lemma 2.3.Every nice graph is determined by its Laplacian spectrum.
We will prove Lemma 2.3 in full detail in Section 4. As a brief outline: the first step in the proof of Lemma 2.3 is to prove that any graph G ′ with the same Laplacian spectrum as a nice graph G is itself nice (with the same parameters ℓ, k).This "localises" the problem: if we only have to consider nice graphs, we can give a much more explicit combinatorial meaning to certain spectral statistics (most crucially, we can give a combinatorial interpretation of the Laplacian spectral moments6 in terms of closed walks around the unique cycle C).This localisation step crucially uses the matrix-tree theorem to show that G ′ is connected (once we know that G ′ is connected, certain spectral inequalities on various degree statistics allow us to deduce that G ′ has a single cycle, then that it is sun-like and then that it is nice).We remark that similar ideas were previously used by Boulet [4] to prove that so-called "sun graphs" are determined by their Laplacian spectrum.
After localising the problem, the second step is to show how to "decode" a specific nice graph using spectral information: i.e., assuming that G ′ is nice, we use spectral information to discover which nice graph it is.The idea for this step is to "inductively explore the graph around its 1-hub" using spectral moments: assuming we know the positions of all the 2-hubs up to distance d of the 1-hub, we can use the (2d + 2)-th spectral moment to see whether there is a 2-hub at distance d + 1 from the 1-hub.Very roughly speaking, the reason this is possible is that the spectral moments can be interpreted as certain weighted sums over closed walks on C. If a closed walk "interacts with 2-hubs" i times, then the weight of the walk is divisible by 2, so parity considerations allow us to distinguish closed walks involving the 1-hub from closed walks which only involve 2-hubs.
Remark 2.4.For this "decoding" step, there is no advantage of the Laplacian spectrum over the adjacency spectrum.In fact, it would have been much more convenient to work with the adjacency spectrum, as the spectral moments of the adjacency matrix have a much more direct combinatorial interpretation than the spectral moments of the Laplacian matrix.Indeed, the i-th spectral moment of the adjacency matrix simply counts the number of closed walks of length i.For a nice graph, every nontrivial closed walk can be obtained by starting with a closed walk in the unique cycle C, and then choosing some hubs in the walk at which we go in and out of a leaf.Every time we go in and out of a leaf at a 2-hub, we have an even number of choices, whereas every time we go in and out of a leaf at a 1-hub, we have an odd number of choices.
Remark 2.5.There are some parallels between our 2-step strategy to prove Lemma 2.3 and a similar 2-step strategy that was recently applied with great success in the continuous case (i.e., in the "hearing the shape of a drum" setting).Indeed, a recent breakthrough result of Hezari and Zelditch [24] is that ellipses with low eccentricity are determined by their spectrum.In their proof, the first step is to use certain spectral inequalities to "localise" the problem, showing that any domain whose spectrum matches a low-eccentricity ellipse must be "almost circular".Then, the second step is to pin down the precise shape of the domain, taking advantage of the fact that the spectrum determines certain information about closed billiard trajectories inside the domain, and applying powerful results due to Avila, De Simoi and Kaloshin [2] to study such trajectories.There is a superficial similarity between closed walks in graphs and closed billiard trajectories in a domain; it is not clear to us whether this connection runs deeper.
An example of a (46, 3)-nice graph.There is one 1-hub v 0 , and three 2-hubs v 1 , v 2 , v 3 .The distances between v 0 and v 1 , between v 1 and v 2 and between v 2 and v 3 are 4, 6 and 4, respectively.
2.2.The signless Laplacian spectrum.As outlined, the next step is to prove an analogue of Lemma 2.3 for the signless Laplacian spectrum: we are able to do this with a mild condition on the length of the cycle ℓ, as follows.
Note that an (ℓ, k)-nice graph is bipartite if and only if ℓ is even, and as we have discussed, for bipartite graphs, the signless Laplacian spectrum is the same as the Laplacian spectrum.So, given Lemma 2.3, in order to prove Lemma 2.6 we just need to show that if ℓ ≡ 2 (mod 4) then every graph with the same signless Laplacian spectrum as an (ℓ, k)-nice graph must be bipartite.
The full details of the proof of Lemma 2.6 appear in Section 5, but to give a brief idea: the only spectral information we need is the product of nonzero eigenvalues.We observe that for every nonbipartite graph the product of nonzero eigenvalues is divisible by 4, and that the assumption ℓ ≡ 2 (mod 4) guarantees that the product of nonzero eigenvalues of G is not divisible by 4. For both of these facts, we use an explicit combinatorial description of the coefficients of the characteristic function of the signless Laplacian matrix, due to Cvetković, Rowlinson and Simić [10].(These coefficients can be expressed as sums of products of eigenvalues via Vieta's formulas; in particular the nonzero coefficient with lowest degree tells us the product of nonzero eigenvalues).
Remark 2.7.Lemma 2.6 implies that if n is odd, then there are exponentially many n-vertex graphs which are determined by their signless Laplacian spectrum.However, there is no bipartite nice graph on an even number of vertices, so, the analogous result for even n is not completely obvious.With a bit more work we were nonetheless able to prove such a result, yielding a version of Theorem 1.4 for the signless Laplacian, as follows.
Theorem 2.8.The number of (unlabelled) n-vertex graphs determined by their signless Laplacian spectrum is at least e cn for some constant c > 0.
To prove Theorem 2.8, we combine Lemma 2.6 with some of the ideas described in the next subsection; the details appear in Appendix A.
2.3.Exponentially many graphs determined by their adjacency spectrum.As briefly mentioned earlier in this outline, there is a close connection between the signless Laplacian spectrum of a graph and the adjacency matrix of its line graph.To be a bit more specific, the nonzero eigenvalues of |L(G)| are in correspondence with the eigenvalues of A(line(G)) different from −2.One might (naïvely) hope that line(G) being determined by its adjacency spectrum is equivalent to G being determined by its signless Laplacian spectrum.If this were true, it would be easy to complete the proof of Theorem 1.4, by considering the family of all n-vertex graphs which are the line graph of some nice graph as in Lemma 2.6.
Unfortunately, this is too much to hope for in general, but quite some theory has been developed in this direction, and we are able to leverage this theory in the special case where G has a large prime number of vertices.Lemma 2.9.There is a constant n 0 such that the following holds.Let G be an (ℓ, k)-nice graph with ℓ ≡ 2 (mod 4), let n = ℓ + 2k + 1 be its number of vertices, and suppose that n is a prime number larger than n 0 .Then line(G) is determined by its adjacency spectrum.
The proof of Lemma 2.9 appears in Section 6.To give a rough idea of the strategy of the proof: recalling Lemma 2.6, in order to prove Lemma 2.9 it suffices to show that if a graph Q has the same (adjacency) spectrum as line(G), then (1) Q = line(H) for some H, and (2) H has the same signless Laplacian spectrum as G.
For (1), we have the Cameron-Goethals-Seidel-Shult theorem at our disposal, which we can use to show that Q is a so-called generalised line graph (except possibly for some "exceptional" connected components with at most 36 vertices).Our main task is to rule out generalised line graphs which are not line graphs.For (2), our task is to show that in the signless Laplacian spectra of G and H, the multiplicities of the zero eigenvalue are the same (all nonzero eigenvalues are guaranteed to be the same).This amounts to showing that G and H have the same number of vertices.
For the first of these two tasks, we observe that if a generalised line graph is not a true line graph, then its adjacency matrix has a zero eigenvalue.So, it suffices to prove that line(G) does not have a zero eigenvalue, i.e., its adjacency matrix has nonzero determinant.We accomplish this by directly computing the determinant of line(G) (this is a little involved, but comes down to a certain recurrence).
For the second of these two tasks, we recall that the adjacency spectrum of a line graph tells us the nonzero eigenvalues of the signless Laplacian spectrum, and in particular tells us the product of these nonzero eigenvalues (this product was already discussed in Section 2.2).Via a direct computation on G, we observe that this product is divisible by n.For each connected component of H, the contribution to this product is always an integer, so if n is a prime number then there must be a single connected component which is "responsible for the factor of n".We are then able to deduce that this component has exactly n vertices and n edges, via a careful case analysis involving a combinatorial interpretation of the multiplicity of the eigenvalue −2.
Of course, even after proving Lemma 2.9 we are not yet done: every nice graph has the same number of edges as vertices, so Lemma 2.9 can only be directly used to prove Theorem 1.4 when n is prime.For general n we consider graphs with two connected components, one of which is the line graph of a nice graph on a prime number of vertices and the other of which is a complete graph.The parameters of the nice graph and the size of the complete graph need to satisfy certain inequalities and number-theoretic properties; the details are a bit complicated and we defer the precise specification to Section 7.
In order to show that all relevant inequalities and number-theoretic properties can be simultaneously satisfied (by exponentially many graphs), we use a quantitative strengthening of Dirichlet's theorem on primes in arithmetic progressions.To actually show that all these graphs are determined by their adjacency spectrum, we proceed similarly to Lemma 2.9, but the details are more complicated.Roughly speaking, we identify the complete graph component using its single large eigenvalue and some numbertheoretic considerations, and then we apply Lemma 2.9.

Preliminaries
In this section we collect a number of general tools and results that will be used throughout the paper.Where possible, we cite the original sources of each of these results, but we remark that many of these results can be found together in certain monographs on algebraic graph theory or graph spectra (see for example [3,5,9,11,16]).
3.1.Basic observations.First, in Section 2 we have already mentioned that the signless Laplacian and the Laplacian spectra coincide for bipartite graphs.).If a graph is bipartite, then its signless Laplacian spectrum is the same as its Laplacian spectrum.Also, we record the near-trivial fact that for all notions of spectrum discussed so far, the spectrum of a graph can be broken down into the spectra of its connected components.Fact 3.2.For any graph G, the spectrum of G (with respect to the adjacency, Laplacian or signless Laplacian matrix) is the multiset union of the spectra of the connected components of G.

Spectral inequalities.
Spectral graph theory provides a range of powerful inequalities on various combinatorial parameters, usually in terms of the largest, second-largest or smallest eigenvalue of the adjacency or Laplacian matrix.In this paper we will only need some simple inequalities concerning the numbers of vertices and edges, and the degrees.Lemma 3.3 ([11, Section 3.2] and [37]).Consider a graph G with n vertices, m edges, and maximum degree ∆.Let λ max be the largest eigenvalue of the adjacency matrix A(G).Then (1) Lemma 3.4 ([13, Theorem 3.7] and [1, Theorem 2]).Let G be a graph, write V and E for its sets of vertices and edges, and ∆ for its maximum degree.Let ρ max be the largest eigenvalue of the Laplacian matrix L(G).Then (1) 3.3.Combinatorial interpretation of the spectral moments.As briefly mentioned in Section 2, in this paper we use the term spectral moments to refer to sums of powers of eigenvalues.
Definition 3.5.For a matrix M ∈ R n×n with spectrum σ, the s-th spectral moment of M is If M is the adjacency matrix of a graph G, then the product is nonzero if and only if there is a closed walk in G running through the vertices indexed by i 1 , . . ., i s (in which case this product is exactly 1).So, spectral moments simply count closed walks of various lengths.For example, the second spectral moment is the number of closed walks of length 2, which is precisely twice the number of edges in G (a closed walk of length 2 simply runs back and forth along an edge, starting at one of its two endpoints).
In our proof of Lemma 2.3 we will need to carefully study Laplacian spectral moments, which can also be interpreted in combinatorial terms (albeit in a more complicated way): Definition 3.6.An s-route in a graph is a sequence of vertices v = (v 1 , . . ., v s ), such that for each index j, either v j v j+1 is an edge or v j = v j+1 (where the subscripts should be interpreted modulo s).That is to say, a route consists of a sequence of s steps: at each step we may either walk along an edge or wait at the current vertex.Letting t be the number of "waiting steps" in the s-route v, we also define w( v) to be the product of deg(v j ) over all waiting steps j, times (−1) s−t .We will repeatedly use Fact 3.7 (for many different s) in our proof of Lemma 2.3.For now, we just record some simple observations for s ≤ 3, which can be straightforwardly proved by considering all possible cases for a route of length s.
In particular, if we know that G has no triangles, then the spectrum of M is enough information to determine v∈V deg(v) s for s ∈ {0, 1, 2, 3}.

3.4.
Combinatorial interpretation of the characteristic coefficients.In addition to spectral moments, another very rich way to extract combinatorial structure from the spectrum is to consider the coefficients of the characteristic polynomial of our matrix of interest.
Definition 3.9.Consider a matrix M ∈ R n×n with spectrum σ, and write its characteristic polynomial det(xI . Then, we define the i-th characteristic coefficient to be (here we have used Vieta's formulas for the coefficients of a polynomial in terms of its roots).
Note that the n-th characteristic coefficient ζ n is the determinant of M .More generally, if we consider the largest s for which ζ s is nonzero, then ζ s is the product of nonzero eigenvalues of M .Recalling the definition det(xI − M ) of the characteristic polynomial, we also have the following observation.Fact 3.10.If M is an integer matrix, then its characteristic coefficients are all integers.Now, the characteristic coefficients of the Laplacian, signless Laplacian and adjacency matrices all have different combinatorial interpretations, as follows.
Definition 3.11.A connected graph is unicyclic if it has exactly one cycle (equivalently, if it has the same number of edges as vertices).If the length of this cycle is even it is even-unicyclic; otherwise it is odd-unicyclic.Now, consider any graph G.
(1) A spanning forest F in G is a subgraph of G which is spanning (i.e., contains all the vertices of G) and whose connected components are trees.Let α(F ) be the product of the numbers of vertices in these trees.(2) A TU-subgraph H of G is a spanning subgraph whose connected components are trees or oddunicyclic.Generalising the definition of α above, let α(H) = 4 c s i=1 n s , where c is the number of odd-unicyclic components in H, and the numbers of vertices in the tree components are n 1 , . . ., n s .
(3) An elementary subgraph X of G is a (not necessarily spanning) subgraph whose connected components are cycles and individual edges.Let β(X) = (−1) c (−2) d , where c and d are the number of edge-components and cycle-components in X, respectively.Let Φ i (G), Ψ i (G) and Ξ i (G) be the sets of spanning forests with i edges, TU-subgraphs with i edges, and elementary subgraphs with i vertices, respectively, in G. respectively.
An immediate corollary (in the Laplacian case, considering the n-th and (n − 1)-th characteristic coefficients) is Kirchhoff's celebrated matrix-tree theorem, as follows.
Theorem 3.13 ([27]).For any n-vertex graph G, the Laplacian L(G) has a zero eigenvalue with multiplicity at least 1.G is connected if and only if the multiplicity of the zero eigenvalue is exactly 1, in which case the number of spanning trees in G is precisely the product of the nonzero eigenvalues divided by n.
(2) If G is not bipartite, then the determinant of |L(G)| is a positive integer divisible by 4.
Proof.Let n be the number of vertices of G, so the determinant of |L(G)| (i.e., its product of eigenvalues) is its n-th characteristic coefficient.Note that a tree on at most n vertices has at most n − 1 edges, so in the description in Theorem 3.12, the only possible contributions to the n-th characteristic coefficient of |L(G)| come from spanning odd-unicyclic subgraphs.If G is bipartite, then clearly there is no such subgraph.On the other hand, if G is not bipartite then it has an odd cycle, and a suitable spanning odd-unicyclic subgraph can be found by iteratively removing edges outside this cycle.Each spanning odd-unicylic subgraph H has α(H) = 4. Since every connected graph has a spanning tree, the (n− 1)-th characteristic coefficient of G is always nonzero (so zero can never be an eigenvalue with multiplicity more than 1).
3.5.Line graphs.In Section 2 we mentioned a correspondence between the Laplacian spectrum of a graph G and the adjacency spectrum of its line graph line(G).To elaborate on this: for a graph with vertices v 1 , . . ., v n and edges e 1 , . . ., e m , consider the incidence matrix N (G) ∈ {0, 1} n×m , where the (i, j)-entry is 1 if and only if v i ∈ e j .Then, it is not hard to see that |L(G)| = N (G)N (G) T  If we know the signless Laplacian spectrum of a graph G, then Proposition 3.15 tells us the spectrum of A(line(G)), except the multiplicity of the eigenvalue −2.In order to determine this multiplicity we just need to know the total multiplicity of all eigenvalues of line(G), i.e., the number of vertices of line(G), i.e., the number of edges of G.We have already seen that this information can be recovered from the signless Laplacian spectrum (Proposition 3.8(2)).So, the signless Laplacian spectrum of G fully determines the adjacency spectrum of line(G).Unfortunately, as discussed in Section 2 it is not quite so easy to go in the other direction: there are examples of line graphs which share their adjacency spectrum with non-line-graphs, and there are examples of graphs G, G ′ which have different numbers of vertices (therefore different signless Laplacian spectra) but for which line(G) and line(G ′ ) have the same adjacency spectrum.
In this subsection we collect a few results related to Proposition 3.15.First, T is a positive semidefinite matrix, so we have the following corollary of Proposition 3.15.Lemma 3.17 ([9, Theorem 2.2.4]).Let H be a connected graph with v vertices and e edges, and let µ −2 be the multiplicity of the eigenvalue −2 in A(line(H)).Then Finally, we state the Cameron-Goethals-Seidel-Shult theorem mentioned in Section 2: all but finitely many connected graphs which share their adjacency spectrum with a line graph are so-called generalised line graphs.Definition 3.18.Let K n be the complete graph on n vertices.A perfect matching in K 2m is a collection of m disjoint edges (covering all the vertices of K 2m ).The cocktailparty graph CP(m) is the graph obtained from K 2m by removing a perfect matching.
For a graph G with vertices v 1 , . . ., v n , and nonnegative integers a 1 , . . ., a n , the generalised line graph line(G; a 1 , . . ., a n ) is defined as follows.First, consider the disjoint union of the graphs line(G), CP(a 1 ), . . ., CP(a n ).
(i.e., we include each of the above graphs as a separate connected component).Then, for each i, add all possible edges between the vertices of CP(a i ) and the vertices of line(G) corresponding to edges of G incident to v i (this means 2a i deg(v i ) added edges for each i).
Note that for any graph G we have line(G; 0, . . ., 0) = line(G).Theorem 3.20 was first proved by de la Vallée Poussin [12].All we will need from Theorem 3.20 is the following (immediate) corollary.
Corollary 3.21.Fix ε > 0 and coprime integers a, d ≥ 1.For any sufficiently large n, there is a prime number between (1 − ε)n and (1 + ε)n which is congruent to a (mod d).

Distinguishing nice graphs by their Laplacian spectrum
In this section we prove Lemma 2.3: nice graphs are determined by their Laplacian spectrum.As discussed in Section 2.1, the first step is to "localise" the problem, showing that any graph with the same Laplacian spectrum as a nice graph is itself nice.First, we adapt some ideas of Boulet [4,Theorem 9] to prove the following lemma, which provides some approximate structure (though does not yet completely determine niceness).Recall the definition of a sun-like graph from Definition 2.2.Lemma 4.1.Let G be an (ℓ, k)-nice graph, and let H be a graph with the same Laplacian spectrum as G. Then H is a sun-like graph whose cycle has length ℓ.Moreover, H has exactly one 1-hub, k different 2-hubs, and no i-hubs for any i > 2.
Proof.Let n = ℓ + 2k + 1 be the number of vertices and edges in G. First of all, by Proposition 3.8( 1) and ( 2), H also has n vertices and n edges, and by Kirchhoff's matrix-tree theorem (Theorem 3.13), H is connected.So, H is unicyclic.In a unicyclic graph, the number of spanning trees is equal to the length of the cycle, so by Kirchhoff's theorem again, the cycle in H has length ℓ.
Next, we study the degrees of vertices of H. Writing E for the set of edges of G, recall from Lemma 3.4(2) that the largest Laplacian eigenvalue ρ max is at most max{deg(u) + deg(v), uv ∈ E} ≤ 6 (in a nice graph, every hub has degree at most 4, every non-hub has degree at most 2, and no two hubs are adjacent).By Lemma 3.4(1), the maximum degree of H is strictly less than ρ max , so H can only have vertices of degree 1,2,3,4 or 5.
Let n i be the number of vertices of degree i in H. Since the definition of a nice graph includes the assumption that ℓ > 12k ≥ 3, there are no triangles in H, so by Proposition 3.8, the Laplacian spectrum determines the number of vertices, the sum of degrees, the sum of squares of degrees and the sum of cubes of degrees.In G, the numbers of vertices with degree 1,2,3 and 4 are 2k + 1, ℓ − k − 1, 1 and k, respectively, so we have ) This system of equations has a one-parameter family of solutions, given by (4.1) and (4.2) together imply that n 2 + n 3 + n 4 + n 5 = ℓ − n 5 (i.e., there are ℓ − n 5 ≤ ℓ vertices with degree at least 2).But H has a cycle of length ℓ, and all the vertices on that cycle have degree at least 2, so we must have n 5 = 0 and all the vertices with degree at least 2 must lie on the cycle.This implies that H is sun-like.
There was only one degree of freedom in our system of equations: knowing that n 5 = 0 allows us to deduce the values of all n i , and in particular n 3 = 1 and n 4 = k.That is to say, there is one 1-hub, k different 2-hubs and no i-hubs for i > 2, as desired.4.1.Decorated routes.Recall the definition of a route from Definition 3.6.The remainder of the proof of Lemma 2.3 proceeds by carefully studying routes in sun-like graphs.In this subsection we introduce a convenient framework for working with such routes.Definition 4.2.Let G be a sun-like graph.A decorated s-route R consists of a route v = (v 1 , . . ., v s ) together with a label "look" or "wait" assigned to each j for which v j = v j+1 and v j is a hub (here arithmetic is mod s).That is to say, recalling that we previously imagined a route v as a closed walk with some "waiting steps", we are now reinterpreting some of the waiting steps as steps where we "look at a hub".
For a hub v, if v j = v j+1 = v and j has the label "look", or if v j = v and v j+1 is one of the leaves attached to j, then we say that the decorated route interacts with v at step j (i.e., interacting with a hub means looking at it or entering one of the leaves attached to it).
For a decorated s-route R, define its multiplicity mult(R) to be the number of different decorated routes that can be obtained by cyclically shifting or reversing R. For example, if R is a trivial route that repeatedly waits at a single vertex, then mult(R) = 1, but in general mult(R) can be as large as 2s.
Consider a decorated s-route R. Suppose that in this decorated route there are r 1 steps where we wait at leaf vertices, and r 2 steps where we wait at cycle vertices (not counting steps in which we look at a hub).Suppose that for each i, there are t i steps where we look at an i-hub.Then, we define the weight of R as That is to say, we accumulate a factor of 2 whenever we wait at some vertex on the cycle (not when we wait at a leaf vertex), and we accumulate a factor of i whenever we look at an i-hub.
Example 4.3.Recall the (46, 3)-nice graph in Figure 1.Write a, b, c for the three vertices between the 1-hub v 0 and the 2-hub v 1 , and let x be one of the leaf vertices attached to v 1 .Then, an example of a route is This route has four "waiting steps" (in the first and last steps we wait at v 0 , at the sixth step we wait at v 1 and at the eighth step we wait at x).
In order to make this route into a decorated route, for each of the steps where we wait at a hub (i.e., the first, sixth and last step) we need to decide whether to reinterpret this step as a step where we "look at the hub".For example, say we label the first step as "look" (and the sixth and last steps are labelled as "wait").This route interacts with v 0 and v 1 , once each (we look at v 0 , and enter a leaf attached to v 1 ).The weight of this decorated route is 2 2 • 1 = 4 (we wait twice at cycle vertices, and look at a 1-hub once).
We then have the following consequence of Fact 3.7.Lemma 4.4.Consider any sun-like graph G whose cycle has length ℓ.For s < ℓ, let D s be the set of all decorated s-routes in G.Then, the s-th spectral moment of L(G) is R∈Ds w(R).
Proof.In undecorated routes (as in Definition 3.6) we accumulate a factor of deg(v) = i + 2 each time we wait at a 2-hub v.For our decorated routes, we have simply broken this down into "waiting" and "looking"; waiting accumulates a factor of 2 (just as it does for a non-hub vertex on the cycle) and looking contributes a factor of i.
Also, recall that in an undecorated route we accumulate a factor of −1 for each step we walk along an edge.We can ignore this factor if we only consider routes less than ℓ: such routes cannot make it all the way around the cycle, so must "retrace their steps" and therefore have an even number of "walking steps".
The reason we have introduced the notion of a decorated route is that if we know the hub distribution of a graph, this is enough information to determine the contribution to the s-th spectral moment from routes which interact with at most one hub.(So, we can focus on routes which interact with multiple hubs, which are key to understanding how the hubs are distributed around the cycle).Lemma 4.5.Let G be a sun-like graph whose cycle has length ℓ, and let k i be the number of i-hubs in G. Let D * s be the set of decorated s-routes which interact with at most one hub (any number of times).Then R∈D * s w(R) only depends on ℓ and (k i ) ∞ i=1 .Proof.Consider two different graphs G, H with the same statistics ℓ and (k i ) ∞ i=1 .We will show that the sum of weights under consideration is the same with respect to G and H. Roughly speaking, the key observation will be that for any route involving a single hub in G, we can "rotate the route around the cycle" to find a corresponding route in H.
The cycles C G and C H in G both have the same length ℓ, so we can fix an isomorphism φ : C G → C H . Fixing an orientation of C H , let χ : C H → C H be the automorphism that "rotates one step clockwise around C H ". Since G, H have the same hub distribution, we can also fix an bijection ψ : C G → C H such that v is an i-hub if and only if ψ(v) is an i-hub.For each v in C G , there is a unique j ∈ Z/ℓZ such that ψ(v) = χ (j) (φ(v)) (i.e., we "make ψ(v) line up with φ(v)" by rotating it j steps around the cycle).Let • Clearly, φ gives us a correspondence between decorated s-routes that don't interact with any hubs in G, and decorated s-routes that don't interact with any hub in H. • For any i-hub v in C G , the isomorphism φ v (together with a bijection between the i leaves attached to v in C G and the i leaves attached to ψ(v) in C H ) gives us a correspondence between decorated s-routes which interact with the single hub v in G, and s-routes which interact with the single hub ψ(v) in H.The above correspondences are weight-preserving, so the desired result follows.

4.2.
Localising to nice graphs.Our first application of the framework in Section 4.1 is to finish the "localisation step" in the proof of Lemma 2.3: every graph with the same spectrum as a nice graph is itself nice.Given Lemma 4.1, this basically comes down to studying distances between hubs.Lemma 4.6.Let H be a graph with the same spectrum as an (ℓ, k)-nice graph G. Then H is an (ℓ, k)-nice graph.
Proof.In this proof, we will omit the word "decorated" (we will have no reason to consider undecorated routes).First, we apply Lemma 4.1 to see that H is a sun-like graph whose cycle has length ℓ, with one 1-hub, k 2-hubs, and no i-hubs for i > 2.
Let η s (H), η s (G) be the sum of weights of s-routes which interact with at least 2 hubs (with respect to H and G, respectively).By Lemmas 4.4 and 4.5, and the fact that ℓ ≥ 15 from Definition 2.2, we have η s (H) = η s (G) for all s ≤ 14 (so, we mostly just write "η s " to indicate this common value).Now, we use the parameters η s to study the structure of H.We break this down into a sequence of claims.
Claim 4.7.In H, the closest pair of hubs is at distance 4.
Proof.Note that η 2d+2 > 0 if and only if there are two hubs whose distance is at most d.Indeed, the shortest way for a route to interact with two hubs is to look at one hub, walk d steps to the next hub, look at it, and walk back; this takes 1 + d + 1 + d = 2d + 2 steps.
The closest pair of hubs in G are at distance 4, so the same is true in H. (Note that 2 • 4 + 2 ≤ 14).
Claim 4.8.In H: (1) the 1-hub has distance 4 from exactly one other hub, and (2) the number of pairs of hubs at distance 4 from each other is the same in G and H.
Proof.The only routes that contribute to η 10 are those routes which walk back and forth between two different hubs at distance 4, looking once at each hub along the way.Each such route contributes a weight of 4, unless one of the hubs is a 1-hub, in which case the route contributes a weight of 2. Also, each such route has multiplicity 10 (all ten cyclic shifts yield different routes, but reversing the order does not yield any further routes).So, η 10 /20 can be interpreted as the number of hubs at distance 4 from the 1-hub, plus two times the number of pairs of 2-hubs at distance 4 from each other.
In G, there is exactly one hub at distance 4 from the 1-hub.So, η 10 (G)/20 = η 10 (H)/20 is odd, meaning that there must be an odd number of hubs at distance 4 from the 1-hub in H.The only possible odd number here is 1, because there is simply no room to put three or more hubs at distance 4 from the 1-hub.
Then, in H and in G, the number of pairs of 2-hubs at distance 4 from each other is (η 10 /20−1)/2.Now, Claims 4.7 and 4.8 show that the contributions to η s (H) and η s (G) from routes which interact with two hubs within distance at most 4 (and no other hubs) are the same.(Formally, this can be proved in a similar way to Lemma 4.5, considering a bijection between the set of pairs of hubs at distance 4 in G, and the set of pairs of hubs at distance 4 in H).Let η ′ s (H), η ′ s (G) be obtained from η s (H) and η s (G) by subtracting these contributions, so η ′ s (H) = η ′ s (G) for s ≤ 14.
Claim 4.9.In H, there are no hubs at distance 5 from each other.
Proof.The only routes which can contribute to η ′ 12 are routes which interact with two different hubs at distance 5 from each other.(By Claim 4.7, every pair of hubs is at distance at least 4 from each other, so routes of length 12 are much too short to interact with three different hubs).Since G has no pair of hubs at distance 5, the same is true for H. Claim 4.10.In H: (1) the 1-hub does not have distance 6 from any other hub, and (2) the number of pairs of hubs at distance 6 from each other is the same in G and H.
Proof.Given Claim 4.9, the only routes which can contribute to η ′ 14 are routes which interact with two different hubs at distance 6. (Routes of length 14 are still too short to interact with three different hubs).
The same considerations as for Claim 4.8 show that η ′ 14 /28 can be interpreted as the number of hubs at distance 6 from the 1-hub, plus two times the number of pairs of 2-hubs at distance 6 from each other.
In G, there is no hub at distance 6 from the 1-hub.So, η ′ 14 (G)/28 = η ′ 14 (H)/28 is even, meaning that there are an even number of hubs at distance 6 from the 1-hub v * in H.The only possible even number here is zero, because if there were two hubs at distance 6 from v * (one on either side), one of these 2-hubs would be at distance 2 from the hub guaranteed by Claim 4.8(1) at distance 4 from v * , and this is ruled out by Claim 4.7.
Then, in H and in G, the number of pairs of 2-hubs at distance 6 from each other is (η ′ 14 /28)/2.Now, Claims 4.7 to 4.10 together imply that H is a (k, ℓ)-nice graph.Indeed, imagine walking around the cycles of G and H, and consider the distances between each pair of consecutive hubs.By Claims 4.7 and 4.9, these distances are either 4 or at least 6.By Claims 4.8(2) and 4.10(2) , the number of consecutive pairs of hubs in H which are at distance 4 or 6 is the same as the number of consecutive pairs of hubs in G which are at distance 4 or 6; this number is exactly k.Recalling that H and G both have exactly k + 1 hubs, it follows that in H we can start from some hub v 0 and walk along the cycle, encountering a new hub every 4 or 6 steps until we reach a final hub v k .By Claims 4.8(1) and 4.10(1), the 1-hub is either v 0 or v k (with distance exactly 4 to its closest 2-hub).We have established that H is (ℓ, k)-nice.

4.3.
Decoding a nice graph.Now, we complete the proof of Lemma 2.3, showing that we can decode a specific nice graph using its Laplacian spectrum.
Proof of Lemma 2.3.As in the proof of Lemma 4.6, we will omit the word "decorated" (we will again have no reason to consider undecorated routes).
Suppose we know that G is an (ℓ, k)-nice graph (for some k ≥ 1 and ℓ > 12k), and suppose we know the spectrum of G.We will show how to use this information to determine exactly which (ℓ, k)-nice graph G is (this suffices to prove Lemma 2.3, by Lemma 4.6).
Specifically, it suffices to determine, for each q ≤ 3k − 1, whether there is a hub at distance 2q from the 1-hub v * .(In a nice graph, every hub is at even distance from v * , and the furthest possible distance between hubs is 4 + 6(k − 1) = 6k − 2).
We proceed by induction.For some q ≤ 3k − 1, suppose we know the positions of all hubs within distance 2q − 1 of v * .We would like to determine whether there is a hub at distance 2q from v * .
Let η s be the sum of weights of s-routes which interact with at least 2 hubs.By Lemma 4.5, we have enough information to determine η s for s < ℓ.We can refine this further: let η ′ s be obtained from η s by subtracting the contribution from all routes which interact only with hubs within distance 2q − 1 of v * .Since our inductive assumption is that we know the positions of all hubs within distance 2q − 1 of v * , we have enough information to determine η ′ s (for s < ℓ).We focus in particular on the quantity η ′ 4q+2 (note that 4q + 2 ≤ 4(3k − 1) + 2 < 12k < ℓ, so we have enough information to determine this quantity).We break down η ′ 4q+2 further: • Let α 4q+2 be the contribution to η ′ 4q+2 from routes which interact with v * , and • Let β 4q+2 (t) be the contribution to η ′ 4q+2 from routes which do not interact with v * , and interact with 2-hubs t times.Note that η ′ 4q+2 = α 4q+2 + ∞ t=2 β 4q+2 (t).Claim 4.11.We have Proof.If there is no hub at distance 2q from v * , then a route of length 4q + 2 is simply too short to interact with v * and with one of the 2-hubs that is not within distance 2q − 1 of v * .If there is a hub v at distance 2q from v * , the only routes which contribute to α 4q+2 are those routes which walk back and forth between v and v * , looking once at v and v * along the way.All these routes are cyclic shifts of each other (so, there are 4q + 2 of them), and each such route contributes a weight of 2.
Proof.Consider a 2-hub v, and write x, y for the leaves attached to v. Consider a route R which at some step j enters x from v (then waits at x for some number of steps before returning to v).We can slightly modify R by simply entering y instead of x at step j (and then waiting at y for the same number of steps before returning to v).
Say that two routes are equivalent if they can be obtained from one another by a sequence of modifications of this type.So, routes in an equivalence class have essentially the same structure, but they may visit different leaves.Now, consider a route R which looks at 2-hubs a times, and enters leaves attached to 2-hubs b times (so, R interacts with 2-hubs a + b times).The equivalence class of R has size 2 b , and the weight of each route in this equivalence class is divisible by 2 a .So, the total weight of this equivalence class is divisible by 2 a+b .
The routes that contribute to β 4q+2 (2) are the routes which interact once each with two different 2-hubs u, v (and do not interact with v * ).Fix such a route R. As above, the equivalence class of R contributes weight divisible by 4, so we just need an additional factor of 2. This comes from the fact that mult(R) is equal to 4q + 2 or 8q + 4 (both of which are divisible by 2).Indeed, all 4q + 2 cyclic shifts of R yield different routes, because there is a unique interaction-with-u step whose position changes with each cyclic shift.Reversing the order of R may or may not yield 4q + 2 additional routes.
Finally, given Claims 4.11 and 4.12, we can determine whether there is a 2-hub at distance 2q from v * simply by checking whether η ′ 4q+2 is divisible by 8 or not.This completes the inductive step.

Determining bipartiteness with the signless Laplacian spectrum
In this section we prove Lemma 2.6.This proof mostly comes down to the following two lemmas.
Definition 5.1.For any graph G, let f |L| (G) be the product of nonzero eigenvalues of |L(G)|.
Proof.Let G 1 , . . ., G c be the connected components of a non-bipartite graph G, and suppose without loss of generality that G 1 is non-bipartite.By Fact 3.10, each f |L| (G i ) is an integer, and by Fact 3.
Lemma 5.3.If G is a connected bipartite unicyclic graph with n vertices, whose cycle has length ℓ, then Proof.Since G is bipartite, its signless Laplacian spectrum is the same as its Laplacian spectrum (by Fact 3.1), so by Kirchhoff's matrix tree theorem (Theorem 3.13), f |L| (G) is n times the number of spanning trees in G (which is ℓ, as we have already observed in the proof of Lemma 4.1).Now we are ready to prove Lemma 2.6.
Proof of Lemma 2.6.Let G be an (ℓ, k) nice graph, for ℓ ≡ 2 (mod 4), and let H be a graph with the same signless Laplacian spectrum as G.As discussed in Section 2.2, given Lemma 2.3 and Fact 3.1, we just need to prove that H is bipartite.
Let n = ℓ + 2k + 1 be the number of vertices in G.By Lemma 5.3, we have f |L| (G) = nℓ.Since ℓ ≡ 2 (mod 4) and n = ℓ + 2k + 1 is odd, f |L| (G) is not divisible by 4. Since G and H have the same spectrum, we have f |L| (G) = f |L| (H), so Lemma 5.2 implies that H is bipartite.

The prime case of the main theorem
In this section we prove Lemma 2.9.As outlined in Section 2.3, we will use the Cameron-Goethals-Seidel-Shult theorem (Theorem 3.19), together with the following fact.Recall the definition of a generalised line graph from Definition 3.18.Lemma 6.1.If a generalised line graph is not a line graph, then its adjacency matrix has a zero eigenvalue.
Proof.Let G be a generalised line graph that is not a line graph.We will show that G has two vertices with the same set of neighbours, meaning that A(G) has two equal rows, so is not invertible and therefore has a zero eigenvalue.
By the definition of a generalised line graph, G contains a cocktailparty graph CP(a) for some a ≥ 1.This cocktailparty graph can be thought of as a complete graph K 2a with a perfect matching removed.Consider one of the edges of this removed perfect matching, and let u and v be its endpoints.Then, u and v have the same neighbourhood (in G), as desired.Now, crucially, line graphs of nice graphs as in Lemma 2.9 do not have zero eigenvalues.Lemma 6.2.Let G be an (ℓ, k)-nice graph with ℓ ≡ 2 (mod 4).Then A(line(G)) does not have a zero eigenvalue.
We will prove Lemma 6.2 by explicitly computing the determinant of A(line(G)) using Theorem 3.12.We defer this computation to Section 6.1, as it is a little involved; first we show how to use it to prove Lemma 2.9 (after stating a definition that will be used in the proofs of Lemma 2.9 and Theorem 1.4).Definition 6.3.For any graph G, let f A (G) be the product of nonzero eigenvalues of A(G) + 2. Equivalently, writing σ for the adjacency spectrum of G, Proof of Lemma 2.9 assuming Lemma 6.2.Consider ℓ, k with ℓ ≡ 2 (mod 4), and let n = ℓ + 2k + 1. Define n 0 = max{f |A| (Q) : Q is a graph on at most 36 vertices}, ( and suppose n is a prime number larger than n 0 .Let G be an (ℓ, k)-nice graph, and suppose that Q is a graph with the same adjacency spectrum as line(G).Our objective is to prove that Q = line(H) for some graph H with n vertices.Indeed, if we are able to prove this, it will follow from Proposition 3.15 that H has the same nonzero signless Laplacian eigenvalues as G, and since H and G have the same number of vertices, the multiplicity of the zero eigenvalue will also be the same in H and G.It will then follow that H and G are isomorphic (hence Q and line(G) are isomorphic) by Lemma 2.6.
Write Q 1 , . . ., Q c for the connected components of Q.By Fact 3.10, each f A (Q i ) is an integer, and by Fact 3.2 we have f On the other hand, by Proposition 3.15 and Lemma 5.3, Recalling that n is a prime number, some f A (Q i ) must be divisible by n.Suppose without loss of generality that f A (Q 1 ) is divisible by n. (6.3) By the Cameron-Goethals-Seidel-Shult theorem (Theorem 3.19), Lemma 6.2, and our assumption n > n 0 from the start of the proof, Q 1 is a line graph.We write Q 1 = line(H 1 ) for some (connected) graph H 1 , with v 1 vertices and e 1 edges.Note that e 1 ≤ n, (6.4) because Q 1 has e 1 vertices and is a connected component of Q, which has n vertices (note that Q has the same number of vertices as line(G), which is n because G has n edges).).This cannot be divisible by 4, because f A (Q) = nℓ is not divisible by 4 (here we are recalling (6.2), and using that n is odd and ℓ ≡ 2 (mod 4)).So, by Lemma 5.2, H 1 is bipartite.
By Lemma 3.17, A(Q) has −2 as an eigenvalue with multiplicity 1, so (using Fact 3.2), either −2 is not an eigenvalue of A(Q 1 ) or it is an eigenvalue with multiplicity 1.
Case 1: −2 is not an eigenvalue of A(Q 1 ).In this case, Lemma 3.17 says that e 1 = v 1 − 1, and H 1 is a tree.The largest TU-subgraph of H 1 is H 1 itself, so by Theorem 3.12 and Proposition 3.15 we have Then, (6.3) says that v 1 is divisible by n. (6.4) says that v 1 − 1 ≤ n, so we must have v 1 = n.It follows that Q 1 = line(H 1 ) has e 1 = n − 1 vertices, meaning that Q only has room for one other component Q 2 , consisting of a single isolated vertex.We then compute n.This is not consistent with the fact that f A (Q) = nℓ (as we observed in (6.2)), so this case cannot actually occur.
Case 2: −2 is an eigenvalue of A(Q 1 ).In this case, Lemma 3.17 says that e 1 = v 1 , and H 1 is an even-unicyclic graph.Let ℓ 1 be the length of the cycle in H 1 , so by Lemma 5.3 we have f By (6.4) we have ℓ 1 ≤ v 1 ≤ n, and (6.3) says that v 1 ℓ 1 is divisible by the prime number n.So, we must have v 1 = n.Since Q 1 = line(H 1 ) has e 1 = v 1 = n vertices, there is no room for any other components: we have proved that Q = Q 1 = line(H 1 ) for some H 1 with n vertices, as desired.
6.1.Computing the determinant of the line graph of a nice graph.In this subsection we prove Lemma 6.2.First, we need some definitions that allow us to discuss the structure of the line graph of a nice graph.Definition 6.4.Let uv be an edge in a graph Q.To add an i-house to uv is to add a set S of i new vertices to Q, and to add all possible edges between vertices in S ∪{u, v}.Then, we say that the subgraph induced by S ∪ {u, v} (which is a complete graph on i + 2 vertices) is an i-house.The vertices u, v are internal and the vertices in S are external.
Note that the line graph of every (ℓ, k)-nice graph (as defined in Definition 2.2) can be obtained by starting with a cycle of length ℓ, then adding a 1-house to one edge and adding 2-houses to k other edges.The distances between pairs of consecutive i-houses are always 3 or 5 (except one longer distance around the cycle).See Figure 2 for an illustration.Now, our objective is to compute the determinant of the line graph of a nice graph.We will be able to reduce this to computing the determinant of a slightly simpler type of graph, which can be studied recursively.
Recall from Definition 3.11 that a spanning elementary subgraph of a graph G is a spanning subgraph (covering all vertices) consisting of vertex-disjoint edges and cycles.For such a subgraph X, recall that β(X) accumulates a factor of −1 for each edge-component, and a factor of −2 for each cycle-component.By Theorem 3.12, the determinant of A(G) is (up to sign) the sum of β(X) over all spanning elementary subgraphs X of G. Definition 6.5.Consider r ≥ 0 and k ≥ 0, and 1 The graph Q(r; a 1 , . . ., a k ) is defined by starting with a path of length r, and adding a 2-house on the a i -th edge of this path, for each i. (See Figure 3 for an illustration).Let q(r; a 1 , . . ., a k ) be the sum of β(X) over all spanning elementary subgraphs X of Q(r; a 1 , . . ., a k ).Lemma 6.6.Let r, k, a 1 , . . ., a k be as in Definition 6.5.For inductive reasons it is convenient to additionally allow r = −1 (in which case Q(r) is the graph with no vertices).
In particular, if r − a k ≥ 2 (or if r ≥ 2 and k = 0), the spanning elementary subgraphs of Q(a 1 , . . ., a k ) can be obtained by taking a spanning elementary subgraph of Q(a 1 , . . ., a k − 2), and adding a single edge-component (see Figure 4).We deduce (2), recalling that each edge-component contributes a weight of −1.
If r − a k = 1, then the aforementioned edge-component covers one of the internal vertices of the final 2-house.There are two different ways to cover the two external vertices in this 2-house by a spanning elementary subgraph: either we can cover them with a single edge or we can cover them, in addition to the remaining internal vertex, with a 3-cycle (see Figure 4).In the first case, we accumulate a factor of −2, and the remaining vertices of the spanning elementary subgraph can be interpreted as a spanning elementary subgraph of Q(r − 2; a 1 , . . ., a k−1 ).In the second case, we accumulate a factor of −1, and the remaining vertices of the spanning elementary subgraph can be interpreted as a spanning elementary subgraph of Q(r − 3; a 1 , . . ., a k−1 ).So, q(r; a 1 , . . ., a k−1 ) = (−1) 2 q(r − 2; a 1 , . . ., a k−1 ) + (−1)(−2)q(r − 3; a 1 , . . ., a k−1 ), yielding (3).
If r = a k , then the final vertex of Q(r; a 1 , . . ., a k ) is an internal vertex of the final 2-house, and does not have degree 1.There are a few different ways to cover the final vertex and the two external vertices of the final house by a spanning elementary subgraph: we could cover just these three vertices with a 3-cycle, or we could cover the entire 2-house (there are three different ways to do this with two disjoint edges, and three different ways to do this with a 4-cycle; see Figure 4).Similar considerations as above yield q(r; a 1 , . . ., a k−1 ) = −2q(r − 1; a 1 , . . ., a k−1 ) + (3(−1) 2 + 3(−2))q(r − 2; a 1 , . . ., a k−1 ), yielding (4).The recurrences described in Corollary 6.7 are sufficient to compute any q(r; a 1 , . . ., a k ), but the general formulas are rather complicated.We consider a restricted class of choices of a 1 , . . ., a k , which will be sufficient for the proof of Lemma 6.2.Corollary 6.7.Suppose a 1 , . . ., a k are odd integers.Then q(r; a 1 , . . ., a k ) = 2k(−1) r/2+1 if r is even, (2k + 1)(−1) (r+1)/2 if r is odd.
Proof.We proceed by induction on k.
Proof of Lemma 6.2.Let b 1 < • • • < b k be the distances of the 2-hubs from the 1-hub in G (so in particular b 1 = 4, and all b i are even).Let D be the sum of β(X) over all spanning elementary subgraphs X of line(G).
Let u * be the tip of the 1-house in line(G).There are four ways for an elementary subgraph to cover u * (pictured in Figure 5): (1) u * could be covered by a long cycle that runs all the way around the nice graph.
(2) u * could be covered by a 3-cycle covering the entire 1-house.
(3) u * could be covered by a single edge, whose other vertex is at distance 3 from the 2-house.(4) u * could be covered by a single edge, whose other vertex is at distance 4 from the 2-house.
Let D 1 , D 2 , D 3 , D 4 be the contributions to D from spanning elementary subgraphs that cover u * in each of the above four ways (in that order).First, D 2 , D 3 , D 4 can be handled with Corollary 6.7, as follows.Recall that ℓ ≡ 2 (mod 4).
For D 2 : apart from the 3-cycle covering the 1-house, the rest of a spanning elementary subgraph corresponds to a spanning elementary subgraph of Q (6.5) For D 3 : apart from the edge covering the tip of the 1-house, the rest of a spanning elementary subgraph corresponds to a spanning elementary subgraph of Q(ℓ − 2; b 1 − 1, . . ., b k − 1), so For D 4 : apart from the edge covering the tip of the 1-house, the rest of a spanning elementary subgraph corresponds to a spanning elementary subgraph of (we can describe the graph in "two different directions").Note that ℓ − b k is even (as the difference of two even numbers), so It remains to consider D 1 .Suppose we have an elementary spanning subgraph which contains a long cycle C covering u * and going around the ℓ-cycle of line(G).There are three different ways that C can interact with each 2-house of line(G) (all of which are pictured at the top of Figure 5).Specifically, there are two ways for C to pass through all 4 vertices of the 2-house, or alternatively C can simply pass through the internal vertices of the 2-house, leaving the remaining two external vertices to be covered by an edge-component.
So, there are 3 k spanning elementary subgraphs that contribute to D 1 .To compute the weight of each such subgraph: first, start with a base weight of −2.For each 2-house, we have three choices; the first two (incorporating the 2-house in the cycle) do not affect the weight, but the third (leaving the external vertices for an edge-component) accumulates a factor of −1.So, Combining (6.5) to (6.8), we see that D = −4, so by Theorem 3.12, the determinant of A(line(G)) is nonzero (it has absolute value 4).

Augmenting the prime case
In this section we show how to use line graphs of nice graphs to define a family of exponentially many graphs that are determined by their adjacency spectrum.This definition includes a number of inequalities and number-theoretic properties which will be used in a somewhat delicate case analysis in the proof of Theorem 1.4 (to rule out various possibilities for graphs which have the same spectrum as one of our graphs of interest, but have different structure).
Definition 7.1.The star graph K 1,n consists of n leaves attached to a single vertex.Note that line(K 1,n ) is the complete graph K n on n vertices.
Let G n be the family of graphs G satisfying the following properties.G1 G has two components.One of these components is an (ℓ, k)-nice graph G 1 (for some parameters ℓ, k satisfying ℓ ≤ max(12k, 15)), and the other of these components is a star graph K 1,n2 (with some number of edges n 2 ).G2 Writing n 1 = ℓ + 2k + 1 for the number of edges and vertices of G 1 , we have n 1 + n 2 = n (i.e., G has n edges).G3 n 1 is a sufficiently large prime number (larger than n 0 from (6.1)).G4 ℓ = 2p for a sufficiently large prime number p (larger than n 0 from (6.1)).G5 n 2 ≡ 3 (mod 4).G6 n 1 < n 2 .G7 2n 1 + p − 2 > n.G8 2n 1 − ℓ + 2 < n 2 − 1. (Note that G3 and G4 imply that G 1 satisfies the properties in Lemma 2.9).Let Q n = line(G n ) be the family of line graphs of graphs in G n .
Then, the following two lemmas imply Theorem 1.4.

Lemma 7.2.
There is a constant c > 0 such that |Q n | ≥ e cn for every sufficiently large n.Lemma 7.3.Every graph in Q n is determined by its (adjacency) spectrum.
Case II.In the second case, write P 1 , P 2 , P 3 for the three internally disjoint paths, and let ℓ 1 , ℓ 2 , ℓ 3 be their lengths.For H to be non-biparitite, it cannot be the case that ℓ 1 , ℓ 2 , ℓ 3 all have the same parity.Suppose without loss of generality that ℓ 1 is even and ℓ 2 is odd.
• If ℓ 3 is even, then the largest TU-subgraphs of H are the odd-unicyclic subgraphs obtained by deleting a single edge from P 1 or P 3 .So, by Theorem 3.12 we have f |L| (H) = 4(ℓ 1 + ℓ 3 ), which is divisible by 8. • If ℓ 3 is odd, then the largest TU-subgraphs of H are the odd-unicyclic subgraphs obtained by deleting a single edge from P 2 or P 3 .So, by Theorem 3.12 we have f |L| (H) = 4(ℓ 2 + ℓ 3 ), which is divisible by 8.
We also need the following consequence of Lemma 3.3(2), allowing us to recognise a complete graph by its number of vertices and its largest eigenvalue.Lemma 7.5.Let G be a graph with n vertices, such that A(G) has n − 1 as an eigenvalue.Then G is a complete graph.
Proof.Let e be the number of edges of G, and let λ max be the largest eigenvalue of A(G).Then Lemma 3.3(2) implies that n − 1 ≤ λ max ≤ √ 2e − n + 1, or equivalently that e ≥ n(n − 1)/2; the only graph with this many edges is a complete graph.Now we prove Lemma 7.3, completing the proof of Theorem 1.4.
Proof of Lemma 7.3.Let G ∈ G n (with parameters ℓ, k, n 2 , n 1 , p as in Definition 7.1), and let Q be a graph with the same adjacency spectrum as line(G).Our objective is to prove that Q has the complete graph K n2 as a connected component.Indeed, if we are able to prove this, then we can apply Lemma 2.9 to the graph that remains after removing this K n2 component (here we are using Fact 3.2 to see that removing this K n2 component has a predictable effect on the spectrum).
As is well-known (see for example [5, Section 1.4.1]), the eigenvalues of a complete graph K n2 are −1 (with multiplicity n 2 − 1) and n 2 − 1 (with multiplicity 1).So (by Fact 3.2), as in the proof of Lemma 2.9 we can see that in the spectrum of A(Q) there is no zero eigenvalue, and −2 appears as an eigenvalue with multiplicity 1.Also, by Fact 3.2, Proposition 3.15, and Lemma 5.In particular, Q 2 has at least ∆ 2 + 1 ≥ n 2 vertices, so by Lemma 7.4 and the assumptions n 1 > n 2 ≥ n 0 from G3 and G6, we can write Q 2 = line(H 2 ) for some graph H 2 .Let v 2 be the number of vertices in H 2 .Now, we consider the cases in Lemma 7.4 (1A, 1B and 2) for the structure of H 2 .We will show that all these cases lead to contradiction except 1B (i.e., H 2 is a tree), and in that case we will prove that v 2 = n 2 + 1 vertices (so H 2 has n 2 edges and Q 2 has n 2 vertices; this suffices to show that Q 2 is our desired K n2 component, by Lemma 7.5).
Case 1A: H 2 is odd-unicyclic.In this case we have f A (Q 2 ) = 4. Since f A (Q) is divisible by the prime number n 1 , there must be some component Q 1 = Q 2 such that f A (Q 1 ) is divisible by n 1 .Recall from (7.1) that f A (Q) is not divisible by 8, so f A (Q 1 ) must be odd.By Lemma 7.4 (and the assumption n 1 > n 0 from G3), we can write Q 1 = line(H 1 ) for some graph H 1 .Let v 1 be the number of vertices in H 1 .Considering all cases of Lemma 7.4, the only possibility that leads to f A (Q 1 ) being odd is the case where H 1 is a tree (whose number of vertices v 1 is odd and divisible by n 1 ).Now, we can proceed similarly to Case 1 in the proof of Lemma 2.9.
Note that Q 1 has v 1 −1 vertices and Q 2 has v 2 ≥ ∆ 2 +1 ≥ n 2 vertices (for the latter inequality, we used (7.2)).So, v 1 − 1 + n 2 ≤ n, or equivalently v 1 ≤ n 1 + 1.Since v 1 is divisible by n 1 we must have v 1 = n 1 , so Q only has room for one other component Q 3 (other than Q 1 , Q 2 ), consisting of a single isolated vertex.If this component exists, it has f A (Q 3 ) = 1.We then compute f A (Q) = f A (Q 1 )f A (Q 2 ) = 4n 1 , which is not consistent with (7.1).So, this case is impossible.

Fact 3 . 7 .
For any graph G, let R s be the set of all s-routes in G.Then, the s-th spectral moments of L(G) and |L(G)| are v∈Rs w( v) and v∈Rs |w( v)|, respectively.

Proposition 3 . 8 .
Consider any graph G with n vertices and m edges, and write V for its set of vertices.Let M = L(G) or M = |L(G)|, and let µ s be the s-th spectral moment of M .Then (1)

Theorem 3 .
12 ([10, Theorem 4.4], [22, Theorem 3] and [3, Theorem 7.5]).For any graph G, the i-th characteristic coefficients of L(G), |L(G)| and A(G) are and A(line(G)) = N (G) T N (G) − 2I.Since the nonzero eigenvalues of N N T are the same as the nonzero eigenvalues of N T N (including multiplicities), we have the following.Proposition 3.15.Consider any graph G and any λ = 0.Then, λ is an eigenvalue of |L(G)| with multiplicity m if and only if λ − 2 is an eigenvalue of A(line(G)) with multiplicity m.

Fact 3 . 16 .
For any graph G, the eigenvalues of A(line(G)) are all at least −2.Also, Proposition 3.14 gives us a combinatorial description of the multiplicity of the zero eigenvalue of G. Together with Proposition 3.15, this can be used to give a combinatorial description of the multiplicity of −2 as an eigenvalue of A(line(G)).

Theorem 3 .
19 ([6, Theorem 4.3 and 4.10]).Suppose Q is a connected graph on more than 36 vertices, all of whose adjacency eigenvalues are at least −2.Then Q is a generalised line graph.

3. 6 .
Primes in arithmetic progressions.As mentioned in Section 2, we will need a quantitative version of Dirichlet's theorem, counting primes in a given arithmetic progression.Theorem 3.20.Fix coprime integers a, d ≥ 1, and let ϕ(d) > 0 be the number of integers up to d which are relatively prime to d.Let π a,d (n) be the number of primes up to n which are congruent to a (mod d).Then lim n→∞ π a,d (n) n/ log n = 1 ϕ(d) .

Figure 3 .
Figure 3.An illustration of the graph Q(13; 3, 7, 13), with 2-houses on the third, seventh, and thirteenth edges of the underlying path.

Figure 4 .
Figure 4.All the possible ways to cover the final vertex (and possibly the external vertices in the final 2-house) in a spanning elementary subgraph of a graph Q(r; a 1 , . . ., a k ).

Figure 5 .
Figure 5. Four possible ways to cover the tip of the 1-house 3 we havef A (Q) = (n 2 + 1)n 1 ℓ = 2(n 2 + 1)n 1 p. (7.1) Recalling (7.1) and G5, we see that f A (Q) is not divisible by 8 (so by Fact 3.2, f A (Q i ) is not divisible by 8 for any connected component Q i of Q) Now, Fact 3.2 tells us that some connected component Q 2 of Q must have n 2 − 1 as an eigenvalue.Let ∆ 2 be the maximum degree of Q 2 , so by Lemma 3.3(1) we have ∆ 2 ≥ n 2 − 1. (7.2)