1 Introduction

The friendship graph \(F_k\) (also called Dutch windmill graph, or \(k\)-fan) consists of \(k\) edge-disjoints triangles that meet in one vertex. The famous friendship theorem (see Erdős et al. [6] and Wilf [8]) states that these are the only graphs with the property that every pair of vertices contains a unique common neighbor (neighbors are called friends in the friendship theorem). Clearly \(F_k\) has \(2k+1\) vertices and \(3k\) edges, and \(F_1=K_3\). For convenience we shall assume that \(k\ge 2\). The adjacency matrix \(A_k\) of \(F_k\) has spectrum \(\{\frac{1}{2}\pm \frac{1}{2}\sqrt{1+8k},\, 1^{k-1}, \, -1^k\}\) (multiplicities are denoted as exponents). Wang et al. [7] conjectured that \(F_k\) is determined by the spectrum of the adjacency matrix \(A_k\). This conjecture caused some activity on the spectral characterization of \(F_k\). Das [5] claimed to have a proof, but Abdollahi et al. [1] found a mistake. In addition, these authors give correct proofs in some special cases. In this paper, we prove that the conjecture from [7] is true if \(k\ne 16\), and show that there is just one counterexample if \(k=16\).

Although it has been conjectured by the second author that almost all graphs are determined by the spectrum of the adjacency matrix, it is very often difficult to prove the spectral characterization of a given graph (or family of graphs). The spectrum of \(A_k\) has two interesting properties that give much information on the structure of the graph and bring a possible proof of the mentioned conjecture within reach. The first property is that the second largest eigenvalue equals \(1\), and the second smallest eigenvalue is equal to \(-1\). By eigenvalue interlacing (see for example [2], Sect. 2.5) it follows that every induced subgraph of a graph cospectral with \(F_k\) must have the second largest eigenvalue at most 1, and the second smallest eigenvalue at least \(-1\). This gives a considerable reduction on the possible induced subgraphs (see Lemma 3). The second property is that \(A_k^2-I\) has rank \(2\) and is positive semi-definite. This leads to conditions for the structure of \(A_k^2\) (see Lemma 2). Because of these observations, we take a more general approach, and consider all graphs with the mentioned two properties. Thus, we determine the graphs with only two eigenvalues \(r\) and \(s\) (\(r>1\), \(s<-1\)) different from \(\pm 1\). We shall see that the disconnected ones have all components but one equal to \(K_2\). The connected ones come in three infinite families (one of which contains the friendship graphs) and seven sporadic graphs. No two non-isomorphic connected ones have the same spectrum, but a disconnected graph can be cospectral and non-isomorphic to another one. In particular, one of the sporadic graphs extended with some isolated edges is cospectral with \(F_{16}\).

2 Basics and tools

We start with a well-known result on equitable partitions (see for example Sect. 2.3 of [2]). 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 characteristic 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

The matrix \(A\) has the following two kinds of eigenvectors and eigenvalues:

  1. (i)

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

  2. (ii)

    The eigenvectors orthogonal to the columns of \(\chi _\mathcal{{P}}\); the corresponding eigenvalues of \(A\) remain unchanged if some scalar multiple of the all-one block \(J\) is added to block \(A_{i,j}\) for each \(i,j\in \{1,\ldots ,m\}\).

The reverse identity matrix of order \(n\) is denoted by \(R_n\). Thus \(R_{2k}\) is the adjacency matrix of \(kK_2\), the disjoint union of \(k\) edges. We illustrate the use of Lemma 1 with an example. Consider the following partitioned matrix \(A\) with quotient matrix \(Q\):

$$\begin{aligned} A = \left[ \begin{array}{c@{\quad }c} J-I_{a}&{} J\\ J &{} R_{2k} \end{array}\right] \ ,\ Q = \left[ \begin{array}{c@{\quad }c} a-1 &{} 2k\\ a &{} 1 \end{array}\right] . \end{aligned}$$

The eigenvalues of \(Q\) are \((a\pm \sqrt{a^2+8ak-4a+4})/2\), so they are also eigenvalues of \(A\). The other eigenvalues of \(A\) remain the same if we subtract \(J\) from the blocks equal to \(J\) or \(J-I_a\). Then \(A\) and \(Q\) become

$$\begin{aligned} A' =\left[ \begin{array}{c@{\quad }c} -I_a &{} O\\ O &{} R_{2k} \end{array}\right] \ ,\ Q' = \left[ \begin{array}{c@{\quad }c} -1 &{} 0\\ 0 &{} 1 \end{array}\right] . \end{aligned}$$

The part of the spectrum of \(A'\), which is not in the spectrum of \(Q'\) is \(\{1^{k-1},\, -1^{k+a-1}\}\). Thus we find that \(A\) has spectrum \(\{(a\pm \sqrt{a^2+8ak-4a+4})/2,\, 1^{k-1},\, -1^{k+a-1}\}\). We see that a graph \(G\) with adjacency matrix \(A\) belongs to the classification. Note that if \(a=1\), then \(G\) is the friendship graph \(F_k\).

Proposition 1

Let \(G\) be a graph with \(n\) vertices and adjacency matrix \(A\).

  1. (i)

    If \(A\) has all its eigenvalues equal to \(\pm 1\), then \(G=\frac{n}{2}K_2\).

  2. (ii)

    If \(A\) has all but one eigenvalue equal to \(\pm 1\), then \(G\) is the disjoint union of complete graphs with all but one connected components equal to \(K_2\).

  3. (iii)

    If \(A\) has just two eigenvalues, \(r\) and \(s\) (\(r\ge s\)) different from \(\pm 1\), then \(r>1\) and \(s<-1\), or \(G\) is a disjoint union of complete graphs with two connected components different from \(K_2\).

Proof

If \(A\) has an eigenvalue \(s<-1\), then the largest eigenvalue of \(A\) is greater than \(1\) (by the Perron–Frobenius theorem); this case is captured by the first option of \((iii)\). If \(A\) has smallest eigenvalue at least \(-1\), then \(G\) is the disjoint union of cliques (see for example [3]), which leads to the other possibilities. \(\square \)

Lemma 2

Suppose \(r>1\) and \(s<-1\) are the only eigenvalues of \(G\) different from \(\pm 1\).

  1. (i)

    One connected component of \(G\) has all vertex degrees at least \(2\), and all other connected components are isomorphic to \(K_2\).

  2. (ii)

    Suppose \(u\) and \(v\) are distinct vertices with degrees \(d_u\) and \(d_v\), and each neighbor of \(u\) is also a neighbor of \(v\). Then \(d_v-d_u \ge 3\).

Proof

\((i)\) Suppose \(u\) is a vertex of degree \(1\). Let \(v\) be the neighbor of \(u\), and assume that \(v\) has another neighbor \(w\) of degree \(d_w\). The \(2\times 2\) principal submatrix of \(A^2-I\) corresponding to \(u\) and \(w\) equals

$$\begin{aligned} S = \left[ \begin{array}{c@{\quad }c} 0 &{} 1\\ 1 &{} d_w-1 \end{array}\right] . \end{aligned}$$

We have \(\det S<0\), while \(A^2-I\) is positive semi-definite. This is a contradiction proving that \(v\) has degree 1.

\((ii)\) The \(2\times 2\) principal submatrix of \(A^2-I\) corresponding to \(u\) and \(v\) equals

$$\begin{aligned} S = \left[ \begin{array}{c@{\quad }c} d_u-1 &{} d_u\\ d_u &{} d_v-1 \end{array}\right] . \end{aligned}$$

If \(d_v\le d_u +2\), then \(\det S \le (d_u-1)(d_u+1)-d_u^2 < 0\), contradiction. \(\square \)

Note that \((ii)\) of Lemma 2 implies that two vertices \(u\) and \(v\) cannot have the same set of neighbors.

Define \(\mathcal{{G}}\) to be the set of connected graphs with eigenvalues \(r>1\) and \(s<-1\), and all other eigenvalues equal to \(\pm 1\). By the above results, in order to find all graphs with at most two eigenvalues different from \(\pm 1\), it suffices to determine \(\mathcal{{G}}\). We start with a list of forbidden induced subgraphs.

Lemma 3

No graph in \(\mathcal{{G}}\) has one of the graphs presented in Fig. 1 is an induced subgraph.

Fig. 1
figure 1

Forbidden induced subgraphs

Proof

Each graph in Fig. 1 has its second largest eigenvalue \(\lambda _2\) strictly greater than 1, or its second smallest eigenvalue \(\lambda _{n\!-\!1}\) strictly less than \(-1\). Interlacing completes the proof. \(\square \)

3 Main results

We begin with the description of the graphs in \(\mathcal{{G}}\). The proof will be given in the next section.

Theorem 1

The adjacency matrices and spectra of the graphs in \(\mathcal{{G}}\) are as follows:

  1. (i)

    \(\left[ \begin{array}{c@{\quad }c} O &{}J-I_{m}\\ J-I_{m} &{} O \end{array}\right] \ (m\ge 3)\) with spectrum \( \left\{ \pm (m-1),\ 1^{m-1},\ -1^{m-1} \right\} \),

  2. (ii)

    \(\left[ \begin{array}{c@{\quad }c} J-I_a &{} J \\ J &{} R_{2k} \end{array}\right] \ (a\ge 1,\ k\ge 2 )\) with spectrum \(\left\{ \frac{a}{2}\pm \frac{1}{2}\sqrt{a^2+8ak-4a+4}, 1^{k-1},\ -1^{a+k-1} \right\} \),

  3. (iii)

    \(\left[ \begin{array}{c@{\quad }c} R_{2\ell } &{} J\\ J &{} R_{2m} \end{array}\right] \ (\ell \ge m\ge 2)\) with spectrum \(\left\{ 1 \pm 2\sqrt{\ell m},\ 1^{\ell +m-2},\ -1^{\ell +m} \right\} \),

  4. (iv)

    \(\left[ \begin{array}{c@{\quad }c} O &{}N\\ N^\top &{} O \end{array}\right] \) where \(N= \left[ \begin{array}{c@{\quad }c} 1 &{} \varvec{1}^\top \\ \varvec{1} &{} I_4 \end{array}\right] \), or \(N= \left[ \begin{array}{c@{\quad }c} J-I_3 &{} J\\ O &{} J-I_3 \end{array}\right] \) with spectra \(\left\{ \pm 3,\ 1^4,\ -1^4 \right\} \), and \(\left\{ \pm 4,\ 1^5,\ -1^5 \right\} \), respectively,

  5. (v)

    \( \left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a &{} J &{}\varvec{1}\\ J&{}J-I_{b}&{}\varvec{0}\\ \varvec{1}^\top &{}\varvec{0}^\top &{}0 \end{array}\right] \) where \((a,b)=(6,5)\), \((4,6)\), or \((3,8)\) with spectra \(\left\{ 4\pm 2\sqrt{10},\ 1^1,\ -1^9 \right\} \), \(\left\{ (7\pm \sqrt{129})/2,\ 1^1,\ -1^{8}\right\} \), \(\left\{ 4\pm \sqrt{37},\ 1^1,\ -1^{9}\right\} \), respectively,

  6. (vi)

    \(\left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a&{}J&{}O\\ J&{}O&{}J-I_m\\ O&{}J-I_m&{}O \end{array}\right] \) where \((a,m)=(3,5)\) or \((4,4)\) with spectra \(\left\{ (1\pm \sqrt{129})/2,\ 1^{5},\ -1^{6} \right\} \), \(\left\{ 1\pm 2\sqrt{7},\ 1^4,\ -1^6 \right\} \), respectively.

We see that \(\mathcal{{G}}\) contains three infinite families and seven sporadic graphs. From the given spectra it follows straightforwardly that

Corollary 1

No two graphs in \(\mathcal{{G}}\) are cospectral.

Theorem 2

Suppose \(G\) and \(G'\) are non-isomorphic cospectral graphs with at most two eigenvalues different from \(\pm 1\). Then \(G=H+\alpha K_2\) and \(G'=H'+\alpha ' K_2\), where \(H\) and \(H'\) are one of the following pairs of graphs in \(\mathcal{{G}}\):

  • Both \(H\) and \(H'\) are of type \((iii)\) with parameters \((\ell ,m)\) and \((\ell ',m')\), where \(\ell m=\ell ' m'\),

  • One is of type \((iii)\) with \(\ell ,m\ge 2\), and the other of type \((ii)\) with \(a=2\) and \(k=\ell m\),

  • One is of type \((iv)\) and the other one of type \((i)\) with \(m=4\), or \(5\), respectively,

  • One is of type \((ii)\) with \((a,k)=(1,16)\) or \((2,7)\), and the other of type \((vi)\) with \((a,m)=(3,5)\), or \((4,4)\), respectively.

Proof

The disjoint union of complete graphs in known to be determined by its spectrum (see [3]). So, by Proposition 1 and Lemma 2\((i)\), \(G\) and \(G'\) must have the described form. Next observe that \(H\) and \(H'\) share the eigenvalues \(r>1\) and \(s<-1\). Using this we easily find the given possibilities for \(H\) and \(H'\). \(\square \).

By taking \(\alpha =0\) in Theorem 2, we find the graphs in \(\mathcal{{G}}\) having a non-isomorphic cospectral mate.

Corollary 2

A graph \(G\in \mathcal{{G}}\) is determined by its spectrum, unless \(G\) is one of the following

  • \(G\) is of type \((ii)\) and \((a,k)=(1,16)\) or \((2,7)\),

  • \(G\) is of type \((ii)\) with \(a=2\) and \(k\) a composite number,

  • \(G\) is of type \((iii)\) and \(\ell m\) has a divisor strictly between \(\ell \) and \(m\),

  • \(G\) is of type \((iv)\).

Thus we have that the friendship graph \(F_k\), which is Case \((ii)\) with \(a=1\), is determined by its spectrum, except when \(k=16\). The friendship graph \(F_{16}\) is cospectral with \(G + 10 K_2\), where \(G\in \mathcal{{G}}\) is of type \((vi)\) with \((a,m)=(3,5)\).

4 The proof

Here we give the proof of Theorem 1.

In all cases we see that the corresponding quotient matrix has two eigenvalues different from \(\pm 1\) and with Lemma 1 it straightforwardly follows that the remaining eigenvalues of the graph are all equal to \(\pm 1\). So all graphs of Theorem 1 are in \(\mathcal{{G}}\).

Van Dam and Spence [4] classified all bipartite graphs with four distinct eigenvalues. Their Proposition 8 gives the bipartite graphs in \(\mathcal{{G}}\), described in \((i)\) and \((iv)\).

In the remainder of the proof, it is assumed that \(G\in \mathcal{{G}}\) is not bipartite. We define \(C\) to be a clique in \(G\) with maximum size. By Lemma 3 (graphs A and N) \(G\) contains no induced odd cycles of length five or more, therefore \(|C|\ge 3\). If there are more than one cliques of maximum size, we choose one for which the number of outgoing edges is minimal. The following lemma is the key to our approach.

Lemma 4

The vertex set of \(C\) can be partitioned into two nonempty subsets \(X\) and \(Y\) (say), such that the neighborhood of any vertex outside \(C\) intersects \(C\) in \(X\), \(Y\), or \(\emptyset \).

Proof

If \(|C|=n-1\) the result is obvious. So assume \(3\le |C|\le n-2\). Take vertices \(x\) and \(y\) outside \(C\), and let \(X\) and \(Y\) consist of the neighbors of \(x\) and \(y\) in \(C\), respectively. Note that \(X\) and \(Y\) are proper subsets of \(C\), since otherwise \(C\) is not maximal. Suppose that \(X\cap Y\ne \emptyset \) but \(X\not \subset Y\). Then there exist vertices \(u\in X\cap Y\) and \(v\in X\setminus Y\). Let \(w\) be a vertex in \(C\setminus X\). Then the subgraph induced by \(\{u,v,w,x,y\}\) is a forbidden subgraph D, E, or F. Therefore, if \(X\) and \(Y\) are not disjoint, then \(X\subset Y\), and analogously \(Y\subset X\). Thus \(X\cap Y\ne \emptyset \) implies \(X=Y\). If \(X\cap Y=\emptyset \), assume there exist vertices \(u\in X\), \(v\in Y\), and \(z\in C\setminus (X\cup Y)\), then \(\{z,u,v,x,y\}\) induces a forbidden subgraph B or C. This implies that if \(X\) and \(Y\) are disjoint and both nonempty, then \(X\cup Y = C\). \(\square \)

Let \(\Gamma X\) and \(\Gamma Y\) denote the set of vertices outside \(C\) adjacent to \(X\) and \(Y\), respectively. The set of vertices not adjacent to any vertex of \(C\) will be denoted by \(\Omega \). Some of these sets may be empty, but clearly \(\Gamma X\) or \(\Gamma Y\) is nonempty (otherwise \(G\) would be disconnected or complete). We choose \(\Gamma X\ne \emptyset \) and distinguish three cases: (1) both \(\Gamma Y\) and \(\Omega \) are empty, (2) only \(\Omega \) is empty, and (3) \(\Omega \) is nonempty. For convenience we define \(a=|X|\), \(b=|Y|\), and \(c=|C|=a+b\).

4.1 \(\Gamma Y\) and \(\Omega \) are empty

Assume \(b=1\). Then \(\Gamma X\) contains no edges, because \(C\) is maximal. The vertex \(v\in C\setminus X\) and a vertex in \(\Gamma X\) are nonadjacent with the same neighbors, which is impossible by Lemma 2\((ii)\). Therefore \(b\ge 2\). Choose two vertices \(u\) and \(v\) from \(Y\), and choose \(w\in X\). Suppose \(x\in \Gamma X\) has two neighbors \(y\) and \(z\) in \(\Gamma X\), then \(\{u,v,w,x,y,z\}\) induces graph J or \(\{v,w,x,y,z\}\) induces graph D from Fig. 1, therefore, any vertex \(x\in \Gamma X\) has at most one neighbor in \(\Gamma X\). By Lemma 2\((ii)\), it is not possible that \(x\in \Gamma X\) has one neighbor in \(\Gamma X\) and \(y\in \Gamma X\) has no neighbor in \(\Gamma X\). We conclude that either all vertices of \(\Gamma X\) have exactly one neighbor in \(\Gamma X\), or \(\Gamma X\) contains no edges. In the first case \(G\) has the following adjacency matrix \(A\) with quotient matrix \(Q\):

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a &{} J &{} J \\ J &{} J-I_{b} &{} O \\ J &{} O &{} R_{n-c} \end{array}\right] ,\ Q=\left[ \begin{array}{c@{\quad }c@{\quad }c} a-1 &{} b &{} n-c \\ a &{} b-1 &{} 0 \\ a &{} 0 &{} 1 \end{array}\right] . \end{aligned}$$

Computing \(\det (Q+I)\) and \(\det (Q-I)\) shows that \(Q\) has no eigenvalue \(-1\), and \(Q\) has an eigenvalue \(1\) if and only if \(b=2\). In case \(b=2\) we can rewrite \(A\) as

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c} J-I_a &{} J \\ J&{} R_{2k} \end{array}\right] \end{aligned}$$

with \(k\ge 2\). Thus we obtain the graphs of Case \((ii)\).

If \(\Gamma X\) has no edges and at least two vertices, then these two vertices have the same neighbors, contradiction. So \(|\Gamma X|=1\) and we find

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a &{} J &{} \varvec{1} \\ J &{} J-I_{b} &{} \varvec{0} \\ \varvec{1}^\top &{} \varvec{0}^\top &{} 0 \end{array}\right] ,\ Q=\left[ \begin{array}{c@{\quad }c@{\quad }c} a-1 &{} b &{} 1 \\ a &{} b-1 &{} 0 \\ a &{} 0 &{} 0 \end{array}\right] . \end{aligned}$$

The quotient matrix \(Q\) has no eigenvalue \(-1\) and an eigenvalue 1 if and only if \((a,b)=(6,5)\), \((4,6)\), or \((3,8)\), which leads to Case \((v)\).

4.2 \(\Gamma X\) and \(\Gamma Y\) are nonempty, and \(\Omega \) is empty

Claim 1

\(a\le 2\ \text { or } b\le 2\).

Proof

Suppose \(a\ge b\ge 3\) and suppose \(\{x,y\}\) is an edge in \(\Gamma Y\). Let \(u,v, \hbox {and } w\) be three distinct vertices in \(X\), and choose \(z\in Y\). Then \(\{u,v,w,x,y,z\}\) induces graph J from Lemma 3. So \(\Gamma Y\) contains no edges. Similarly \(\Gamma X\) has no edges. Now forbidden subgraph S from Lemma 3 implies that a vertex in \(\Gamma X\) is adjacent to all, or all but one vertices in \(\Gamma Y\) (and vice versa). Let \(x\) be a vertex in \(\Gamma X\) and suppose \(x\) is adjacent to all vertices of \(\Gamma Y\). Suppose \(y\) is another vertex in \(\Gamma X\). Then, by Lemma 2\((ii)\), \(y\) has fewer than \(|\Gamma Y|-2\) neighbors in \(\Gamma Y\), contradiction. Similarly, if \(|\Gamma Y|\ge 2\) each vertex in \(\Gamma Y\) is adjacent to all but one vertices of \(\Gamma X\). This implies that the subgraph induced by \(\Gamma X \cup \Gamma Y\) is \(K_2\) or a complete bipartite graph with the edges of a perfect matching deleted. So we find two possible block structures and quotient matrices for \(A\):

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c@{\quad }c@{\quad }c} J-I_a &{} J &{} \varvec{1} &{} \varvec{0} \\ J &{} J-I_b &{} \varvec{0} &{} \varvec{1} \\ \varvec{1}^\top &{} \varvec{0}^\top &{} 0 &{} 1 \\ \varvec{0}^\top &{} \varvec{1}^\top &{} 1 &{} 0 \end{array}\right] , Q=\left[ \begin{array}{c@{\quad }c@{\quad }c@{\quad }c} a-1 &{} b &{} 1 &{} 0 \\ a &{} b-1 &{} 0 &{} 1 \\ a &{} 0 &{} 0 &{} 1 \\ 0 &{} b &{} 1 &{} 0 \\ \end{array}\right] , \end{aligned}$$

or

$$\begin{aligned} A\!=\!\left[ \begin{array}{c@{\quad }c@{\quad }c@{\quad }c} J-I_a &{} J &{} J &{} O \\ J &{} J-I_b &{} O &{} J \\ J &{} O &{} O &{} J-I_m \\ O &{} J &{} J-I_m &{} O \end{array}\right] ,\ Q\!=\!\left[ \begin{array}{c@{\quad }c@{\quad }c@{\quad }c} a-1 &{} b &{} m &{} 0 \\ a &{} b-1 &{} 0 &{} m \\ a &{} 0 &{} 0 &{} m-1 \\ 0 &{} b &{} m-1 &{} 0 \\ \end{array}\right] , \end{aligned}$$

where \(m = |\Gamma X|=|\Gamma Y|\). In the former case, \(Q\) has eigenvalue 1 with multiplicity 1 for \((a,b)\in \{(4,4),(6,3)\}\), but none of the other 3 eigenvalues are equal to \(\pm 1\). In the latter case, \(Q\) has eigenvalue 1 with multiplicity 1 for \((a,b,m)\in \{(3,3,8),(4,3,7),(4,4,6),(6,6,5),(8,5,5)\}\), but none of the other 3 eigenvalues are equal to \(\pm 1\). For any other \(a\), \(b\), and \(m\), neither quotient matrix has any eigenvalue equal to \(\pm 1\) (this follows straightforwardly by solving \(\det (Q+I)=0\) and \(\det (Q-I)=0\)). Therefore, the corresponding graphs are not in \(\mathcal{{G}}\). \(\square \)

Claim 2

\(a=b=2\).

Proof

First assume \(a > b = 1\). Then \(\Gamma X\) contains no edges, because otherwise \(C\) would not be maximal. Consider \(u\in Y\) and \(x\in \Gamma X\). Then \(x\) is adjacent to all vertices in \(\Gamma Y\), since otherwise interchanging \(u\) and \(x\) would give another maximal clique of size \(c\) with fewer outgoing edges. This implies that \(u\) and \(x\) have the same neighbors, contradiction.

Next assume \(a > b = 2\). We see that \(a\ge 3\) implies that \(\Gamma Y\) contains no edges, otherwise \(G\) contains forbidden graph J. Take a vertex \(u\in X\) and a vertex \(x\in \Gamma X\). If \(y\) and \(z\) are distinct vertices in \(\Gamma X\) both adjacent to \(x\), then the graph induced by \(\{u,x,y,z\}\cup Y\) is a forbidden subgraph (equal to J or containing D) of Lemma 3. Therefore \(\Gamma X\) contains no intersecting edges. Like before, forbidden graph S implies that every vertex in \(\Gamma X\) is adjacent to all, or all vertices but one in \(\Gamma Y\). Consider a vertex \(x\in \Gamma X\) with no neighbors in \(\Gamma X\) and a vertex \(y\in Y\). The neighborhood of \(x\) is contained in that of \(y\), but \(d_y\le d_x+2\), which contradicts Lemma 2\((ii)\). We conclude that the graph induced by \(\Gamma X\) is a disjoint union of edges. Suppose \(\{x,y\}\) is an edge in \(\Gamma X\). Then both \(x\) and \(y\) are adjacent to all vertices of \(\Gamma Y\), since otherwise interchanging \(\{x,y\}\) with \(Y\) would give another clique in \(G\) of size \(c\) with fewer outgoing edges. Thus, every vertex of \(\Gamma X\) is adjacent to every vertex of \(\Gamma Y\).

Applying Lemma 2\((ii)\) to two vertices in \(\Gamma Y\) yields a contradiction, thus \(|\Gamma Y|=1\). We find the following \(A\) and \(Q\):

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a &{} J &{} \varvec{0} \\ J &{} R_{2m} &{} \varvec{1} \\ \varvec{0}^\top &{} \varvec{1}^\top &{} 0 \end{array}\right] ,\ Q=\left[ \begin{array}{c@{\quad }c@{\quad }c} a-1 &{} 2m &{} 0 \\ a &{} 1 &{} 1 \\ 0 &{} 2m &{} 0 \end{array}\right] . \end{aligned}$$

It follows straightforwardly that \(Q\) has no eigenvalue equal to \(\pm 1\). This is a contradiction, and we conclude that \(a=b=2\). \(\square \)

We have \(a=b=2\). By the same argument as above it follows that \(\Gamma X\) only contains disjoint edges. Forbidden graphs H and S imply that every vertex of \(\Gamma X\) is adjacent to all, or all vertices but one of \(\Gamma Y\). Then, as before, a vertex in \(\Gamma X\) with no neighbors in \(\Gamma X\) and a vertex in \(Y\) violate Lemma 2\((ii)\), so \(\Gamma X\) induces a disjoint union of edges. Thus, every vertex of \(\Gamma X\) must be adjacent to every vertex of \(\Gamma Y\). The same holds if \(X\) and \(Y\) are interchanged. Thus we can conclude that \(A\) is as follows:

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c} R_{2\ell } &{} J \\ J &{} R_{2m} \end{array}\right] \end{aligned}$$

with \(\ell ,m\ge 2\), where \(2\ell =|\Gamma X|+2\) and \(2m=|\Gamma Y|+2\). This leads to Case \((iii)\). \(\square \)

4.3 \(\Omega \) is not empty

Since \(G\) is connected there exists an edge \(\{x,z\}\) with \(z\in \Omega \) and \(x\in \Gamma X\), or \(x\in \Gamma Y\). Assume \(x\in \Gamma X\), take \(u\in X\), and let \(y\) be a neighbor of \(z\) different from \(x\). If \(y\in \Gamma Y\), then the neighbor \(v\in Y\) of \(y\) together with \(u\), \(x\), \(y\), and \(z\) induce a forbidden subgraph A or B from Lemma 3. Thus, \(y\not \in \Gamma Y\) which means \(y\in \Gamma X \cup \Omega \).

Assume that \(|Y|\ge 2\). Let \(v\) and \(w\) be distinct vertices in \(Y\). If \(y\in \Gamma X\), then \(\{u,v,w,x,y,z\}\) induces a forbidden subgraph of type G or H. If \(y\in \Omega \), then \(\{u,v,w,x,y,z\}\) induces a forbidden subgraph of type K or M. Therefore \(|Y|=1\).

Consider the set \(Y'=Y\cup \Gamma X\) and let \(Z\) be the set of vertices which are not in \(X\) or \(Y'\). Then \(|Y'|\ge 2\), since \(Y\) and \(\Gamma X\) are nonempty, and \(Y'\) contains no edges, since otherwise \(C\) would not be maximal. Therefore \(X,Y'\), and \(Z\) give the following block structure of \(A\):

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a &{} J &{} O \\ J &{} O &{} N \\ O &{} N^\top &{} M \end{array}\right] . \end{aligned}$$

Take three vertices \(u\in X\), \(x\in Y'\), and \(y\in Y'\) with degrees \(d_u\), \(d_x\) and \(d_y\), respectively. Assume \(d_x\le d_y\), and consider the corresponding \(3\times 3\) principal submatrix \(S\) of \(A^2-I\). Then

$$\begin{aligned} S=\left[ \begin{array}{c@{\quad }c@{\quad }c} d_u-1 &{} a-1 &{} a-1 \\ a-1 &{} d_x-1 &{} d_{xy} \\ a-1 &{} d_{xy}&{} d_y-1 \end{array}\right] , \end{aligned}$$

where \(d_{xy}\) is the number of common neighbors of \(x\) and \(y\). Write \(S=(a-1)J + S'\), then

$$\begin{aligned} S' = \left[ \begin{array}{c@{\quad }c} d_u-a &{} \varvec{0}^\top \\ \varvec{0} &{} T \end{array}\right] \text { with } T = \left[ \begin{array}{c@{\quad }c} d_x-a &{} d_{xy}-a+1\\ d_{xy}-a+1 &{} d_y-a \end{array}\right] . \end{aligned}$$

Note that \(d_u>a\), and \(d_x,d_y\ge a\). Forbidden graphs H and T imply that \(y\) has at most two neighbors in \(Z\) that are not neighbors of \(x\). More precisely, if \(y\) has two adjacent neighbors that are not neighbors of \(x\), then these two neighbors of \(y\) together with \(x, y\) and two vertices in \(X\) induce forbidden subgraph H. Otherwise, if \(y\) has three neighbors that are not neighbors of \(x\), then these three neighbors of \(y\) form an independent set and together with \(x, y\) and two vertices in \(X\), induce forbidden subgraph T. Thus, \(d_x\le d_y \le d_{xy}+2\le d_x+2\).

If \(T\) is positive definite, then so are \(S'\) and \(S\), which contradicts rank\(\, S \le 2\). Therefore \(\det T = (d_x-a)(d_y-a)-(d_{xy}-a+1)^2 \le 0\). If \(d_x=d_{xy}\) then \(d_y\ge d_x+3\) (by Lemma 2\((ii)\)), contradiction. Also if \(d_x\ge d_{xy}+1\), then \(\det T > 0\) unless \(d_x=d_y=d_{xy}+1\). We conclude that \(d_x=d_y=d_{xy}+1\), and we find the following two possible structures for \(N\):

$$\begin{aligned} N=[\, O\ \, J\!-\!I\ \, J\,]\ , \text { or } N=[\, O\,\ I\,\ J\, ]. \end{aligned}$$

Suppose a vertex \(z\in Z\) has two neighbors \(x\) and \(y\) in \(Z\). Take three vertices \(u\), \(v\), and \(w\) in \(C\). Then \(\{u,v,w,x,y,z\}\) induces or contains a forbidden subgraph G, H, J, K, L, M, P, Q, C, or D from Lemma 3. So a vertex \(x\in Z\) has at most one neighbor in \(Z\), and since all vertices have degree at least two, \(z\) is adjacent to a vertex of \(Y'\), hence \(N=[\, J\!-\!I\ \, J\,]\) or \(N=[\, I\,\ J\, ]\). Partition \(Z=Z_1\cup Z_2\) according to the structure on \(N\), so that the vertices in \(Z_2\) are adjacent to all vertices of \(Y'\).

Suppose \(\{y,z\}\) is an edge in \(Z\), and suppose there is a vertex \(x\in Y'\) adjacent to \(y\) but not to \(z\). Take \(u\in X\) and let \(v\in Y'\) be a neighbor of \(z\). Then \(\{u,v,x,y,z\}\) induces a forbidden subgraph A or B. So \(y\) and \(z\) have the same set of neighbors in \(Y'\), and hence \(y,z\in Z_2\). Take \(w\in Z_1\). Then \(w\) has no neighbor in \(Z\), and hence has at least two neighbors in \(Y'\) so \(N=[\, J\!-\!I\ \, J\,]\). If \(w\in Z_1\) and \(z\in Z_2\), then every neighbor of \(w\) is also a neighbor of \(z\), but the degrees of \(z\) and \(w\) differ by two. This is impossible by Lemma 2\((ii)\). Clearly \(|Z_1|=|Y'|\) so \(Z_1\) is not empty. The conclusion is that \(Z_2\) is empty and we find the following \(A\) and \(Q\):

$$\begin{aligned} A=\left[ \begin{array}{c@{\quad }c@{\quad }c} J-I_a &{} J &{} O \\ J &{} O &{} J-I_m \\ O &{} J-I_m &{} O \end{array}\right] \, , \ Q=\left[ \begin{array}{c@{\quad }c@{\quad }c} a-1 &{} m &{} 0 \\ a &{} 0 &{} m-1 \\ 0 &{} m-1 &{} 0 \end{array}\right] , \end{aligned}$$

where \(m=|Y'|=|Z|\). The matrix \(Q\) has all three eigenvalues unequal to \(\pm 1\), except when \((a,m)\) equals \((4,4)\) or \((3,5)\). This leads to Case \((vi)\).\(\square \)