Abstract
We determine all graphs for which the adjacency matrix has at most two eigenvalues (multiplicities included) not equal to \(2\), or 0, and determine which of these graphs are determined by their adjacency spectrum.
Similar content being viewed by others
Avoid common mistakes on your manuscript.
1 Introduction
In an earlier paper [3] we determined the class \(\mathcal G\) of graphs with at most two adjacency eigenvalues (multiplicities included) different from \(\pm 1\). The classification was motivated by the question whether the friendship graph is determined by its spectrum. Here we deal with the class \(\mathcal H\) of graphs for which the adjacency matrix A has all but at most two eigenvalues equal to \(2\) or 0. Equivalently, \(A+I\) has at most two eigenvalues different from \(\pm 1\). The class \(\mathcal H\) is in some sense complementary to \(\mathcal G\). Indeed, many graphs in \(\mathcal G\) (including the friendship graphs) are the complements of graphs in \(\mathcal H\). In particular it easily follows that a regular graph is in \(\mathcal G\) if and only if its complement is in \(\mathcal H\). But for nonregular graphs there is no such relation.
Note that a graph from \(\mathcal H\) remains in \(\mathcal H\) if we add or delete isolated vertices. Let \(\mathcal H'\) be the set of graphs in \(\mathcal H\) with no isolated vertices. Then it clearly suffices to determine all graphs in \(\mathcal H'\).
It turns out that \(\mathcal H'\) contains several infinite families and some sporadic graphs, and that relatively few graphs in \(\mathcal H'\) have a cospectral mate. Thus we find many graphs with four distinct eigenvalues which are determined by their adjacency spectrum; see [5] for some discussion on this phenomenon.
The major part of our proof deals with graphs in \(\mathcal H'\) with two positive eigenvalues. These graphs have least eigenvalues \(2\) and have been classified, see for example [4]. However, using this classification is not straightforward, and we decided to start from scratch using mainly linear algebra. The most important tool is eigenvalue interlacing, which states that if \(\lambda _1(A)\ge \cdots \ge \lambda _n(A)\) are the eigenvalues of a symmetric matrix A of order n, and \(\lambda _1(B)\ge \cdots \ge \lambda _m(B)\) are the eigenvalues of a principal submatrix B of A or order m, then
Another important tool is the following well known result on equitable partitions (we refer to [2] for these tools and many other results on spectral graph theory). Consider a partition \({{\mathcal {P}}}=\{V_1,\ldots ,V_m\}\) of the set \(V=\{1,\ldots ,n\}\). The characteristic matrix \(\chi _{\mathcal {P}}\) of \({\mathcal {P}}\) is the \(n\times m\) matrix whose columns are the character vectors of \(V_1,\ldots ,V_m\). Consider a symmetric matrix A of order n, with rows and columns partitioned according to \({\mathcal {P}}\). The partition of A is equitable if each submatrix \(A_{i,j}\) formed by the rows of \(V_i\) and the columns of \(V_j\) has constant row sums \(q_{i,j}\). The \(m\times m\) matrix \(Q=(q_{i,j})\) is called the quotient matrix of A with respect to \({\mathcal {P}}\).
Lemma 1.1
The matrix A has the following two kinds of eigenvectors and eigenvalues:

(i)
The eigenvectors in the column space of \(\chi _{\mathcal {P}}\); the corresponding eigenvalues coincide with the eigenvalues of Q.

(ii)
The eigenvectors orthogonal to the columns of \(\chi _{\mathcal {P}}\); the corresponding eigenvalues of A remain unchanged if some scalar multiple of the allone block J is added to block \(A_{i,j}\) for each \(i,j\in \{1,\ldots ,m\}\).
The allones and allzeros vector of dimension m is denoted by \(\mathbf{1}_m\) (or \(\mathbf{1}\)) and \(\mathbf{0}_m\) (or \(\mathbf{0}\)), respectively. We denote the \(m\times n\) allones matrix by \(J_{m,n}\) (or just J), the allzeros matrix by O, and the identity matrix of order n by \(I_n\), or I.
2 Graphs in \(\mathcal {H'}\) with just one positive eigenvalue
It is known (see [7]) that a graph with just one positive adjacency eigenvalue is a complete multipartite graph, possibly extended with a number of isolated vertices. Thus we have to find the complete multipartite graphs in \(\mathcal H'\).
Theorem 2.1
If a graph \(G\in \mathcal{H'}\) has one positive eigenvalue, then G is one of the following:

\(G_0(\ell ,m)=K_{\ell ,m}\) with spectrum \(\{0^{\ell +m2},~\pm \sqrt{\ell m}\}\) (\(\ell \ge m\ge 1\)),

\(G_1=K_{1,1,3}\) with spectrum \(\{2,~1,~0^2,~3\}\),

\(G_2(k,m)=K_{2,\ldots ,2,m}\) with spectrum \(\{2^{k2},~0^{k+m2},~k2\pm \sqrt{k^2+2(k1)(m2)}\}\) (\(m\ge 1\)), where \(k\ge 3\) is the number of classes.
Proof
Let \(\mathcal{H}_1'\) be the set of complete multipartite graph in \(\mathcal H'\), and let G be a complete kpartite graph in \(\mathcal{H}_1'\). Then \(k\ge 2\), and \(k=2\) gives \(G_0(\ell ,m)\). Assume \(k\ge 3\). The graph \(K_{2,3,3}\) has two eigenvalues less than \(2\), so by interlacing, G does not contain \(K_{2,3,3}\) as an induced subgraph. So, if no class has size 1, then \(G=G_2(k,m)\) with \(m\ge 2\).
Suppose there are \(k_1\ge 1\) classes of size 1 and assume \(k\ge k_1+3\). Then at least one class has size 2, and at most one class has size greater than 2 (because \(K_{2,3,3}\) is a forbidden induced subgraph). If one class has size \(m\ge 3\), then the adjacency matrix A of G admits an equitable partition with quotient matrix
By Lemma 1.1, the eigenvalues of Q are also eigenvalues of A, but Q has three eigenvalues different from \(2\) and 0, so \(G\not \in \mathcal{H}_1'\). If \(k_1\ge 3\), then \(A+I\) has at least 3 equal rows, and hence A has an eigenvalue \(1\) of multiplicity at least 2, and therefore \(G\not \in \mathcal{H}'_1\). If \(k_1=2\) and G contains \(K_{2,3}\) (which has smallest eigenvalue \(\sqrt{6}<2\)), then G has an eigenvalue equal to \(1\), and an eigenvalue less than \(2\), so \(G\not \in \mathcal{H}_1'\).
So only \(K_{1,2,\ldots ,2}\), \(K_{1,\ell ,m}\), \(K_{1,1,m}\), and \(K_{1,1,2,\ldots ,2}\) are not covered yet by the above cases, and one easily checks that only \(K_{1,2,\ldots ,2}=G_2(k,1)\) and \(K_{1,1,3}=G_1\) survive. The eigenvalues readily follow by use of Lemma 1.1, or from [6]. \(\square \)
The graph \(K_{2,\ldots ,2}\) with \(k\ge 1\) classes is also known as the cocktail party graph, usually denoted by CP(k). We will write C(k) for the adjacency matrix of CP(k). The spectrum of CP(k) equals \(\{2^{k1},~0^k,~2k2\}\). Note that CP(k) with \(k\ge 2\) and \(K_{1,4}\) are the only graphs in \(\mathcal H'\) with just one eigenvalue different from \(2\) or 0. Clearly there is no graph in \(\mathcal H'\) with no positive eigenvalue, so we have the following result: (The disjoint union of two graphs G and \(G'\) is denoted by \(G+G'\), and mG denotes m disjoint copies of G.)
Theorem 2.2
Suppose G is a graph with n vertices and at most one eigenvalue different from \(2\) and 0, then \(G=nK_1\), \(G=K_{1,4}+(n5)K_1\), or \(G=CP(k)+(n2k)K_1\) with \(k\ge 2\).
Corollary 2.3
If G is a disconnected graph in \(\mathcal H'\), then G is one of the following:

\(G_3=2K_{1,4}\) with spectrum \(\{2^2,~0^{8},~2^2\}\),

\(G_4(k)=K_{1,4}+CP(k)\) with spectrum \(\{2^k,~0^{k+3},~2,~2k2\} (k\ge 2)\),

\(G_5(k,\ell )=CP(k)+CP(\ell )\) with spectrum \(\{2^{k+\ell 2},~0^{k+\ell },~2\ell 2,~2k2\} (k\ge \ell \ge 2)\).
Proof
Suppose \(G\in \mathcal{H'}\) has c components, then each component has at least one edge, and therefore at least one positive eigenvalue. Thus G has c positive eigenvalues. So, if G is disconnected then \(c=2\), and each component is \(K_{1,4}\) or CP(k) with \(k\ge 2\). \(\square \)
3 Graphs in \(\mathcal H'\) with two positive eigenvalues
In this section we determine the set \(\mathcal{H}_2'\) of connected graphs in \(\mathcal{H}'\) with two positive eigenvalues. We start with some tools.
Proposition 3.1
Let A be the adjacency matrix of a graph \(G\in \mathcal{H}_2'\), and define \(E=A(A+2I)\). Then E is positive semidefinite and rank\((E)=2\).
We call a pair of vectors \(\mathbf{v}\) and \(\mathbf{w}\in \{0,1\}^n\) almost equal whenever \(\mathbf{v}\) and \(\mathbf{w}\) have different weights, and differ in at most two positions.
Corollary 3.2
If A is the adjacency matrix of a graph \(G\in \mathcal{H}_2'\), then no two columns of \(A+I\) are equal or almost equal.
Proof
Let \(a\ge b\) be the weights of two (almost) equal columns of \(A+I\). Then \(ab\le 2\) and \(E=A(A+2I)=(A+I)^2I\) has the following principal submatrix
which is not positive semidefinite.\(\square \)
Proposition 3.3
The following graphs ((d)(m) represented by their adjacency matrices) are forbidden induced subgraphs for any graph \(G\in \mathcal{H}_2'\).
Proof
Interlacing. Each of the adjacency matrices has smallest eigenvalue less than \(2\), or more than two positive eigenvalues. \(\square \)
Let \(\alpha =\alpha (G)\) be the maximum size of a coclique (that is, an independent set of vertices) in G. We will distinguish a number of cases depending on \(\alpha \).
3.1 Graphs in \(\mathcal{H}_2'\) with \(\alpha =2\)
Theorem 3.4
If \(G\in \mathcal{H}_2'\) and \(\alpha (G)=2\), then G is one of the following graphs (represented by their adjacency matrices):

\(G_6(m):~ \left[ \begin{array}{cc} JI_m &{} I_m \\ I_m &{} JI_m \end{array} \right] \) (\(m\ge 3\)), with spectrum \(\{2^{m1},\, 0^{m1},\, m2,\, m\}\),

\(G_7:~ \left[ \begin{array}{ccc} JI_7 &{} JI_7 &{} \mathbf{0} \\ JI_7 &{} JI_7 &{} \mathbf{1} \\ \mathbf{0}^\top &{} \mathbf{1}^\top &{} 0 \end{array} \right] \) with spectrum \(\{2^7,\, 0^6,\, 7\pm 2\sqrt{7}\}\).
Proof
Let \(\overline{G}\) be the complement of G. Since \(\alpha (G)=2\), \(\overline{G}\) has no triangles. It is wellknown that the complement of an odd cycle \(C_n\) with \(n\ge 5\) has at least three positive eigenvalues. Therefore, by interlacing, \(\overline{G}\) has no induced odd cycle, so \(\overline{G}\) is bipartite and the adjacency matrix A of G has the following structure:
First we claim that \(mm'\le 1\). Indeed, suppose \(m\le m'2\), then \(J_{m'}I\) has eigenvalue \(1\) of multiplicity \(m'1\), and therefore, by interlacing, A has an eigenvalue \(1\) of multiplicity at least \(m'1m>0\), contradiction. So without loss of generality \(m=m'\ge 2\) or \(m=m'1\ge 2\).
Consider four columns \(\mathbf{s}\), \(\mathbf{t}\), \(\mathbf{u}\), \(\mathbf{v}\) of \(A+I\), with \(\mathbf{s}\) and \(\mathbf{t}\) in the first part and \(\mathbf{u}\) and \(\mathbf{v}\) in the second part. Let \(m+a\), \(m+b\) (\(a\le b\)), \(m'+c\), and \(m'+d\) (\(c\le d\)) be the weights of \(\mathbf{s}\), \(\mathbf{t}\), \(\mathbf{u}\) and \(\mathbf{v}\) respectively, and define \(\lambda =\mathbf{s}^\top \mathbf{t}m\) and \(\mu =\mathbf{u}^\top \mathbf{v}m'\). Then these four columns give the following submatrix of \(E=A(A+2I)\):
After Gaussian elimination (subtract the first row from second row and the last row from the third row, and apply a similar action to the columns) we obtain
By Lemma 3.1, rank\((E'')\le 2\), which implies that the upper \(3\times 3\) submatrix of \(E''\) has determinant 0, which leads to
By Lemma 3.2, no two rows of \(A+I\) are equal or almost equal which implies that \(a+b2\lambda 2\ge 0\) with equality if and only if \(a=b=\lambda +1\), and similarly \(c+d2\mu 2\ge 0\) with equality if and only if \(c=d=\mu +1\). If \(a+b2\lambda 2\) and \(c+d2\mu 2\) are both nonzero, then we get
By use of \(a\le b\), \(c\le d\) and \(d\ge \mu +1\) we find \(m+a1\le (a\lambda 1)/2 + (dc)/2 < m\), contradiction. Therefore \(a=b=\lambda +1\) or \(c=d=\mu +1\). When \(m=m'\) this gives \(N=I_m\) or \(N=JI_m\). If \(m=2\) or \(N=JI_m\), then \(G=CP(m)\), and so only \(N=I_m\) with \(m\ge 3\) survives. When \(m=m'1\) we find four possibilities: \(N=[~I_m\ \ \mathbf{0}~],\ [~JI_m\ \ \mathbf{1}~],\ [~I_m\ \ \mathbf{1}~]\), or \([~JI_m\ \ \mathbf{0}~]\). The first two options do not occur, because \(A+I\) has almost equal columns (but note that the second case gives \(K_{1,2,\ldots ,2}\)). For the other cases A has equitable partitions with quotient matrices
respectively. These quotient matrices, and therefore the adjacency matrices, have three eigenvalues different from \(2\) and 0, unless \(m=2\) in the first case (which gives \(K_{1,2,2}\)), and \(m=7\) in the second case. \(\square \)
3.2 Graphs in \(\mathcal{H}_2'\) with \(\alpha \ge 3\)
Theorem 3.5
If \(G\in \mathcal{H}_2'\) and \(\alpha (G)\ge 3\), then G is one of the following graphs (represented by their adjacency matrices):

\(G_8(k,\ell ):~ \left[ \begin{array}{ccc} C(k) &{} O &{} \mathbf{1} \\ O &{} C(\ell ) &{} \mathbf{1} \\ \mathbf{1}^\top &{} \mathbf{1}^\top &{} 0 \end{array} \right] \) with spectrum \(\{2^{k+\ell 1},\ 0^{k+\ell },\ k+\ell 1\pm \sqrt{(k\ell )^2 + 1}\}\) (\(k\ge \ell \ge 1\), \(k\ge 2\)),

\(G_9(k):~ \left[ \begin{array}{cccc} O &{}{} O &{}{} J_{2,3} &{}{} J_{2,2k} \\ O &{}{} JI &{}{} JI &{}{} O \\ J_{3,2} &{}{} JI &{}{} JI &{}{} J_{3,2k} \\ J_{2k,2} &{}{} O &{}{} J_{2k,3} &{}{} C(k) \end{array} \right] \) with spectrum \(\{ 2^{k+3},\, 0^{k+3},\, k+3\pm \sqrt{k^2+3}\}\) (\(k\ge 0\), if \(k=0\), the last block row and column vanish),

\(G_{10}:~\) \(\left[ \begin{array}{ccccccccc} 0&{}0&{}0&{}0&{}1&{}1&{}1&{}1&{}0\\ 0&{}0&{}0&{}0&{}0&{}0&{}0&{}0&{}1\\ 0&{}0&{}0&{}0&{}0&{}0&{}0&{}0&{}1\\ 0&{}0&{}0&{}0&{}1&{}1&{}1&{}1&{}1\\ 1&{}0&{}0&{}1&{}0&{}0&{}1&{}1&{}0\\ 1&{}0&{}0&{}1&{}0&{}0&{}1&{}1&{}1\\ 1&{}0&{}0&{}1&{}1&{}1&{}0&{}0&{}0\\ 1&{}0&{}0&{}1&{}1&{}1&{}0&{}0&{}1\\ 0&{}1&{}1&{}1&{}0&{}1&{}0&{}1&{}0 \end{array} \right] \) with spectrum \(\{2^3,\, 0^4,\, 3\pm \sqrt{2}\}\),

\(G_{11}:~\) \(\left[ \begin{array}{ccccccccc} 0&{}0&{}0&{}0&{}0&{}1&{}1&{}0&{}0\\ 0&{}0&{}0&{}0&{}0&{}1&{}1&{}0&{}0\\ 0&{}0&{}0&{}0&{}0&{}0&{}0&{}1&{}1\\ 0&{}0&{}0&{}0&{}0&{}0&{}0&{}1&{}1\\ 0&{}0&{}0&{}0&{}0&{}1&{}1&{}1&{}1\\ 1&{}1&{}0&{}0&{}1&{}0&{}1&{}0&{}1\\ 1&{}1&{}0&{}0&{}1&{}1&{}0&{}1&{}0\\ 0&{}0&{}1&{}1&{}1&{}0&{}1&{}0&{}1\\ 0&{}0&{}1&{}1&{}1&{}1&{}0&{}1&{}0 \end{array} \right] \) with spectrum \(\{2^3,\ 0^4,\ 2,\ 4\}\),

\(G_{12}:~\) \(\left[ \begin{array}{cccccccc} 0&{}0&{}0&{}0&{}0&{}0&{}1&{}0\\ 0&{}0&{}0&{}0&{}0&{}0&{}1&{}0\\ 0&{}0&{}0&{}0&{}0&{}0&{}0&{}1\\ 0&{}0&{}0&{}0&{}0&{}0&{}0&{}1\\ 0&{}0&{}0&{}0&{}0&{}0&{}1&{}1\\ 0&{}0&{}0&{}0&{}0&{}0&{}1&{}1\\ 1&{}1&{}0&{}0&{}1&{}1&{}0&{}1\\ 0&{}0&{}1&{}1&{}1&{}1&{}1&{}0 \end{array} \right] \) with spectrum \(\{2^2,\ 0^4,\ 1,\ 3\}\).
Proof
Let C be a coclique of G of size \(\alpha \ge 3\). We assume that C has the largest number of outgoing edges among all cocliques of size \(\alpha \). The coclique C, and the remaining vertices of G give the following partition of the adjacency matrix A of G.
First we will prove that the matrix N defined above has one of the following structures:
Suppose rank\((N)\ge 3\). Then N has a \(3\times 3\) submatrix of rank 3, and A has a nonsingular principal submatrix \(A'\) of order 6 containing O of order 3. Interlacing gives \(\lambda _3(A')\ge \lambda _3(O) = 0\). But \(A'\) is nonsingular, so \(\lambda _3(A')>0\), and interlacing gives \(\lambda _3(G)>0\), contradiction. So rank\((N)\le 2\). Suppose \(N=J\), then \(B=JI\), since otherwise G contains the forbidden subgraph \(K_{2,3}\). Thus we have \(G=K_{\alpha ,1,\ldots ,1}\) which has been treated in Sect. 2. We easily have that N has no allzero column (because C is maximal), and no allzero row (because G is connected). We conclude that rank\((N)=2\) and N has one of the structures (i),(ii),(iii),(iv). We will continue the proof by considering these four cases step by step. \(\square \)
3.2.1 Case (i)
We have
Assume \(p\le q\). If \(p=1\), then \(B_1=JI\) (because C is maximal), and \(M=O\) (otherwise there would be another coclique of size \(\alpha \) with more outgoing edges). So G is disconnected, contradiction. If \(p\ge 3\), then the forbidden subgraphs (a), (b), (f), and (i) lead to just six possibilities for (p, q, a, b), being:
One easily checks that none of these give a graph in \(\mathcal{H}_2'\).
So \(p=2\). We assume \(a\ge b\) (if \(p=q=2\) we can do so, and if \(q>p\), then the same forbidden subgraphs as above imply \(b\le 2\), but if \(b=2\) and \(a=1\) then the last two columns of \(A+I\) are equal or almost equal, which contradicts Corollary 3.2). Forbidden subgraph (d) shows that each row of \(B_1\) has weight \(a1\), or \(a2\). If \(B_1\) has an offdiagonal 0, then the two corresponding rows have weight \(a2\), and G has another coclique of size \(\alpha \). The two corresponding rows of M have weight 0, because otherwise the other coclique would have more outgoing edges. So if all rows of \(B_1\) have weight \(a2\), then \(M=O\), and G is disconnected. Therefore at least one row (the first one, say) of \(B_1\) has weight \(a1\). Now rows 1, 3 and \(\alpha +1\) of A give the following submatrix of \(E=A(A+2I)\):
where x is the weight of the first row of M. By Proposition 3.1, rank\((E)=2\), so \(\det (E')=0\), which leads to \(b/a=bxx^2b\). Therefore b / a is an integer, and since \(a\ge b\), we have \(a=b\) and \(2x=a\pm \sqrt{(a2)^28}\). This equation only has an integer solution if \(a=b=5\) and \(x=2\), or 3. Forbidden subgraphs (b) and (f) show that \(q<3\), so \(p=q=2\). Now also \(B_2\) has a row (the first one say) with weight \(b1=4\), and the corresponding row of A together with the three rows considered above, give a \(4\times 4\) submatrix of E of rank 3, contradiction with Proposition 3.1.
3.2.2 Cases (ii) and (iii)
We consider case (iii), but include (ii) by allowing \(a=0\), or \(b=0\) (not both). The forbidden subgraph \(K_{1,5}\) gives \(p+q=\alpha \le 4\). First consider \(\alpha =4\). Then forbidden subgraphs (b) and (i) give \(c=1\), and (b), (k), \((\ell )\) and (j) imply that \(p=q=2\). We assume \(a\ge b\). Moreover, the forbidden graph (m) shows that the last vertex of A is adjacent to all other vertices. So A has the following structure
Like in Sect. 3.2.1, \(p=2\) implies that a row of \(B_1\) has weight \(a1\) or \(a2\). If some row of \(B_1\) (the first one, say) has weight \(a1\), then row 1, 2 and 5 of A give the following submatrix of \(E=A(A+2I)\):
where x is the weight of the first row of M. By Proposition 3.1 \(\det (E')=0\), which implies that \(x\ne b\) and \(x=1+1/(a+1)+1/(bx)\), which has no solution (because \(a\ge b\)). Therefore each row of \(B_1\) has weight \(a2\), and \(B_1=C(a/2)\). But then \(M=O\), since otherwise G would have another coclique of size 4 with more outgoing edges. Also \(B_2=C(b/2)\) (CP(0) is the graph with the empty vertex set), because if a row of \(B_1\) would have weight \(b1\), then the corresponding row of \(A+I\) and row 3 of \(A+I\) are almost equal, which contradicts Corollary 3.2. Now reordering rows and columns of A shows that \(G=G_8(k,\ell )\)). The eigenvalues readily follow by use of Lemma 1.1.
Next we consider \(\alpha =3\). Then we take \(p=1\), \(q=2\). The forbidden graphs (b) and (f) show that \(c=1\) or 2. First suppose \(c=1\). Then
We have \(B_1=JI\), because C is maximal. Let x be the weight of an arbitrary row of M. If \(x=0\), then the corresponding row of \(A+I\) is equal or almost equal to the first row of \(A+I\). So \(x\ge 1\). Because no coclique of size 3 has more outgoing edges than C, it follows that \(x=1\) and \(\mathbf{v}=\mathbf{0}\). Forbidden subgraph (e) gives \(\mathbf{w}=\mathbf{1}\). But now the last row of \(A+I\) is almost equal to the second row. So there is no solution when \(\alpha =3\) and \(c=1\). (Note that the conclusion also holds if \(a=0\) or \(b=0\).)
Suppose \(c=2\). We assume \(p=1\), \(q=2\). Then A has the following structure.
Like before, we have that \(B_1=JI\). Forbidden subgraphs (b) and (e) give that \(B_3=JI\), and \(M_2=J\). Note that if \(a=0\), then the last two rows of \(A+I\) are equal, and if \(b=0\) the first and the fourth row are (almost) equal. So \(a\ge 1\), and \(b\ge 1\). Moreover, subgraphs (g) and (h) imply that each row of \(M_1\) equals [0 1], or [1 0]. Also, by the same arguments as before each row of M has weight 1, and each row of \(B_2\) has weight \(b1\) or \(b2\). Consider the submatrix of E made from the second, the fourth and the last two rows of A, and then replace the last two rows and columns by their sum. Then we get
We have rank\((E')\le \text{ rank }(E)=2\), so \(0=\det (E')=2(a2)(ab+2a+2b)\), hence \(a=2\). Thus \(M_1=[\mathbf{1}_2 \ O]\) or \([I_2 \ O]\). However, the second options does not occur, because it would give a column in \(A+I\) which is almost equal to the last column of \(A+I\). Similarly, if a column of M, different from the first one, has weight \(b1\), then the corresponding column in \(A+I\) is almost equal to the last one. So these columns of M all have weight \(b2\). However, the first row and column of M has weight \(b1\), since if some offdiagonal entry (the second, say) of the first row of M is zero, then rows and columns 2, 3, 4, 6, 7 give the forbidden subgraph (e). Now there is just one family of solutions for A, which, after reordering rows and columns shows that \(G=G_9(k)\). The spectrum follows in a straightforward way by use of Lemma 1.1. This finishes cases (ii) and (iii).
3.2.3 Case (iv)
We have the following adjacency matrix.
We assume \(p\le q\). There is a somewhat special behaviour when \(p=r=b=1\), so we treat this case first. Forbidden subgraph (a), (b) and (d) show that \(q\le 3\) and that each row of \(B_1\) has weight at least \(a2\). If some row of \(B_1\) has weight \(a1\), then \(A+I\) has two almost equal rows, hence \(B_1\) is the adjacency matrix of CP(a / 2). Two nonadjacent vertices in CP(a / 2) together with q vertices of C make another coclique in G of size \(\alpha \) which, by assumption, has not more outgoing edges than C. Therefore the two corresponding entries of M cannot both be equal to 1 and therefore the weight x of M satisfies \(x\le a/2\). The first, the second and the last row of A give the following submatrix of \(E=A(A+2I)\):
Proposition 3.1 gives \(\det (E')=0\), which implies \(2x=a\pm \sqrt{(a+2(q3))^24(q3)^2}\). If \(q=1\) we get \(a=9\), which is not possible. If \(q=2\) we get \(a=4\), \(x=2\), which gives \(G_{10}\). If \(q=3\) there is no solution, because G contains a forbidden subgraph (k) or \((\ell )\).
Next we treat the case \(p=q=r=1\) and \(b\ge 2\). Then, like before, forbidden subgraphs (b) and (d) imply that the a row of \(B_1\) has weight \(a1\) or \(a2\). Suppose all rows have weight \(a2\), so \(B_1\) represents CP(a / 2). Now the first, the second and kth row of A (\(4\le k\le a+3\)) give the following submatrix of \(E=A(A+2I)\):
where x is the weight of the corresponding row in M. This matrix is singular, which implies that \(x=0\), or \(x=b\). Since \(b\ge 2\), no row or column of \(B_2\) has weight b, since otherwise \(A+I\) would have two equal or almost equal columns. So \(B_2\) is the adjacency matrix of CP(b / 2), and the columns of M have weight 0 or a. So \(M=O\) or \(M=J\), but \(M=J\) is impossible, because then one vertex of C and two nonadjacent vertices of CP(a / 2) make up a coclique of size 3 with more outgoing edges than than C has. Thus we find an equitable partition of A with quotient matrix
For all positive integers a and b, Q and hence A has at least three eigenvalues different from \(2\) and 0.
We conclude that at least one row of \(B_1\) has weight \(a1\) and find the following submatrix \(E'\) of \(E=A(A+2I)\):
where x is the weight of the corresponding row of M. Now \(\det (E')=0\) gives \(x^2xb+b+b/a = 0\), We assume \(a\ge b\). Then \(b=a\) and \(2x=b\pm \sqrt{(b2)^28}\). This only has an integer solution if \(b=5\). Then \(x=2\) or \(x=3\). It is straightforward to check that there is no matrix A that satisfies all requirements. [A quick way to see this is by extending \(E'\) above to a \(4\times 4\) matrix \(E''\) by considering also a row of \(B_2\) with weight 4. If \(x'\) is the weight of the corresponding row of \(M^\top \), then rank\((E'')=2\) implies that \(x=2\), \(x'=3\) (or vice versa). This is clearly impossible if all rows of \(B_1\) and \(B_2\) have weight 4. However, if a number of rows of \(B_1\) and \(B_2\) have weight 3, then this number is even and the corresponding rows of M and \(M^\top \) have weight 0 or 5 (see above). This gives that the sum of row weights of M is equal to 2 or 1 (mod 5), whilst the column weights add up to 3 or 4 (mod 5),which is of course impossible.] This finishes the case \(p=q=r=1\).
The next case is \(p=r=1\), \(q\ge 2\). Forbidden subgraphs a and b give \(q=2\) and \(b\le 2\), or \(q=3\), \(b=1\). The case \(b=1\) is solved above, so we only need to deal with \(b=q=2\). Then forbidden subgraph (b) gives that \(B_2=JI\). We consider the submatrix \(E'\) of \(E=A(A+2I)\) formed by the first, the second and the last row of A. Then
where x is the weight of the second column of M. We have \(0=\det (E')=a(2x1)2x^2\), which implies \(x=1\), \(a=2\). Now it is straightforward to check that there is no solution.
Finally we consider the case that \(3\le p+r\le q+r\). Forbidden subgraphs (a) and (b) lead to \(p+r\le 4\), \(a\le 2\), \(b\le 2\), \(a\le 1\) if \(p+r=4\), and \(b\le 1\) if \(q+r=4\). This gives only a short list of possibilities for (p, q, r, a, b), being:
Only the first and the last 5tuple correspond to a solution: \(G_{11}\) and \(G_{12}\), respectively.\(\square \)
4 Conclusions
The graphs in \(\mathcal{H}'\) are given in Theorems 2.1, 3.4, 3.5 and Corollary 2.3. The graphs \(G_8(2,2)\) and \(G_{11}\) are the only two nonisomorphic cospectral graphs in \(\mathcal{H}'\). All other pairs of cospectral graphs in \(\mathcal{H}\) consist of pairs of graphs in \(\mathcal{H}'\) with the same nonzero part of the spectrum (see Theorem 4.1 below), where one or both graphs are extended with isolated vertices, such that the numbers of vertices in both graphs are equal. The following theorem follows straightforwardly from the list of graphs in \(\mathcal{H}'\).
Theorem 4.1
Two nonisomorphic graphs \(G,~G'\in \mathcal{H}'\) have equal nonzero parts of the spectrum if and only if one of the following holds:

\(G=G_0(\ell ,m)\ (= K_{\ell ,m})\), \(G'=G_0(\ell ',m')\ (= K_{\ell ',m'})\), where \(\ell m=\ell 'm'\),

\(G,~G'\in \{G_4(k),~G_5(k,2)\}\) (\(k\ge 2\)),

\(G,~G'\in \{G_5(k+1,k),~G_6(2k),~G_8(k,k)\}\) (\(k\ge 2\)),

\(G,~G'\in \{G_6(3),~G_{12}\}\),

\(G,~G'\in \{G_4(4),~G_5(4,2),~G_9(1)\}\),

\(G,~G'\in \{G_4(3),~G_5(3,2),~G_6(4),~G_8(2,2),~G_{11}\}\),

\(G,~G'\in \{G_3,~G_4(2),~G_5(2,2)\}\).
Corollary 4.2
A graph \(G\in \mathcal{H}'\) is not determined by the spectrum of the adjacency matrix if and only if G is one of the following:

\(G_0(\ell ,m)\ (=K_{\ell ,m})\), where \(\ell m\) has a divisor strictly between \(\ell \) and m,

\(G_4(k),~G_5(k+1,k),~G_8(k,k)\) with \(k\ge 2\),

\(G_3,~G_5(4,2),~G_{11},~G_{12}\).
For every graph in \(\mathcal H\) we can decide whether it is determined by the spectrum of the adjacency matrix by use of Theorem 4.1. For example \(CP(k)+ K_1\), which is the complement of the friendship graph, is determined by its spectrum because every graph with the same nonzero part of the spectrum equals \(CP(k)+mK_1\) for some \(m\ge 0\). This result was already proved in [1]. Also the spectral characterisation of complete multipartite graphs is known, see [6].
References
Abdollahi A., Janbaz S., Oboudi M.R.: Graphs cospectral with a friendship graph or its complement. Trans. Comb. 4, 37–52 (2013).
Brouwer A.E., Haemers W.H.: Spectra of Graphs. Universitext. Springer, New York (2012).
Cioabă S.M., Haemers W.H., Vermette J.D., Wong W.: The graphs with all but two eigenvalues equal to \(\pm 1\). J. Algebr. Comb. 41, 887–897 (2015).
Cvetković D., Rowlinson P., Simić S.: Spectral Generalizations of Line Graphs: On Graphs with Least Eigenvalue \(2\). Cambridge University Press, Cambridge (2004).
van Dam E., Koolen J.H., Xia Z.: Graphs with many valencies and few eigenvalues. Electron. J. Linear Algebra 28, 12–24 (2015).
Esser F., Harary F.: On the spectrum of a complete multipartite graph. Eur. J. Comb. 1, 211–218 (1980).
Smith J.H.: Some properties of the spectrum of graphs. In: Guy, R., Hanani, H., Sauer, N., Schönheim, J. (eds.) Combinatorial Structures and Their Applications, pp. 403–406. Gordon and Breach. Science Publ., Inc, New York (1970).
Author information
Authors and Affiliations
Corresponding author
Additional information
Dedicated to Andries E. Brouwer on the occasion of his 65th birthday.
This is one of several papers published in Designs, Codes and Cryptography comprising the special issue in honor of Andries Brouwer’s 65th birthday.
Rights and permissions
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.
About this article
Cite this article
Cioabă, S.M., Haemers, W.H. & Vermette, J.R. The graphs with all but two eigenvalues equal to \(2\) or 0. Des. Codes Cryptogr. 84, 153–163 (2017). https://doi.org/10.1007/s1062301602414
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s1062301602414