An interactive notebook

Spectral Graph Explorer

How does a collection of edges become a rate of agreement? Build a graph, give its vertices a signal, and follow the connection through its Laplacian.

One graph.
Three ways to read it.

Edges · m
8
Components
1
Connectivity · λ₂
0.5858

Color shows eigenmode 2, relative to its mean.

Choose two vertices to add or remove their edge.

01 / Structure

The spectrum of L

Each bar is an eigenvalue. Choose one to see an associated eigenvector on the graph.

Selected modeλ2 = 0.5858

The number of zero eigenvalues is the number of connected components. λ₂ is positive exactly when the graph is connected.

Eigenvector signs are arbitrary. Repeated eigenvalues admit many valid eigenvector bases; the displayed vector is one choice, not a canonical partition.

Inspect the Laplacian matrix L = D − A
Rows and columns use the graph’s vertex labels. Diagonal entries are degrees; −1 indicates an edge.
L12345678
12-100000-1
2-12-100000
30-12-10000
400-12-1000
5000-12-100
60000-12-10
700000-12-1
8-100000-12

Simple, undirected, unweighted graphs. Values are numerical approximations, rounded for display. Editing evaluates the chosen graph; it does not certify a global optimum.

Behind the controls

One graph, three descriptions

The graph records who interacts. Its quadratic form measures disagreement. Its eigenvalues tell us how fast different patterns of disagreement disappear.

Definition

From edges to eigenvalues

For a simple, undirected, unweighted graph, AA is the adjacency matrix and DD records vertex degrees. The second-smallest eigenvalue of LL is its algebraic connectivity. It is positive exactly when the graph is connected.

L=D−A,0=λ1≤λ2≤⋯≤λn.L=D-A,\qquad 0=\lambda_1\leq\lambda_2\leq\cdots\leq\lambda_n.

Classical spectral graph theory; Fiedler (1973).

Identity

A signal measures disagreement across edges

Assign a real value xix_i to each vertex. An edge contributes more energy when its endpoints disagree. Subtracting the mean leaves every edge difference unchanged; write z=x−xˉ1z=x-\bar{x}\mathbf{1}.

E(x)=xTLx=∑{i,j}∈E(xi−xj)2,λ2=min⁡z≠0z⊥1E(z)∥z∥22.E(x)=x^{\mathsf T}Lx=\sum_{\{i,j\}\in E}(x_i-x_j)^2,\qquad \lambda_2=\min_{\substack{z\ne0\\z\perp\mathbf{1}}}\frac{E(z)}{\|z\|_2^2}.
Proof / derivation

Expand each squared edge difference and collect the terms at each vertex. The diagonal terms give DD and the cross terms give −A-A.

Choose an orthonormal eigenbasis with q1=1/nq_1=\mathbf{1}/\sqrt{n}. A centered signal has no q1q_1 component, so its Rayleigh quotient is a weighted average of the remaining eigenvalues. This also works for a disconnected graph, where more zero eigenvalues occur.

z=∑k=2nckqk⟹zTLz∥z∥22=∑k=2nλkck2∑k=2nck2≥λ2.z=\sum_{k=2}^{n}c_kq_k\quad\Longrightarrow\quad \frac{z^{\mathsf T}Lz}{\|z\|_2^2} =\frac{\sum_{k=2}^{n}\lambda_k c_k^2}{\sum_{k=2}^{n}c_k^2}\geq\lambda_2.

Every nonconstant signal, after centering, gives an upper bound on the current graph's λ₂. It does not certify optimality among graphs.

Lemma

The slowest mode controls diffusion

Let every edge exchange signal at unit rate. The global mean stays fixed. For a connected graph, disagreement with that mean decays at least as fast as the envelope below; starting in a λ2\lambda_2 eigenmode attains it.

x˙=−Lx,x(t)=∑k=1ne−λktqkqkTx(0),∥x(t)−xˉ1∥2≤e−λ2t∥x(0)−xˉ1∥2.\begin{aligned} \dot{x}&=-Lx,\qquad x(t)=\sum_{k=1}^{n}e^{-\lambda_k t}q_kq_k^{\mathsf T}x(0),\\[6pt] \|x(t)-\bar{x}\mathbf{1}\|_2&\leq e^{-\lambda_2t}\|x(0)-\bar{x}\mathbf{1}\|_2. \end{aligned}
Proof / derivation

Since 1TL=0\mathbf{1}^{\mathsf T}L=0, the mean is constant. Diagonalizing LL turns the differential equation into independent scalar decays. Every nonconstant mode of a connected graph has eigenvalue at least λ2\lambda_2; squaring its coefficient and summing proves the bound.

For a disconnected graph, each component keeps its own average. The same inequality holds with λ2=0\lambda_2=0, but it no longer guarantees convergence to a single global value.

An elementary consequence of the spectral decomposition. Time is dimensionless in this explorer.

A connection to the project

An extremal example you can inspect

The complete bipartite preset joins each of two vertices to all the others. Its spectrum, counted with multiplicity, is

spec⁡L(K2,n−2)={0,2,…,2⏟n−3,n−2,n},n≥4.\operatorname{spec} L(K_{2,n-2})=\{0,\underbrace{2,\ldots,2}_{n-3},n-2,n\},\qquad n\geq4.

The public theorem proves that no simple graph on the same number of vertices and exactly 2(n−2)2(n-2) edges has algebraic connectivity greater than 2. This makes K2,n−2K_{2,n-2} a maximizer; it does not establish uniqueness. The numerical explorer lets you inspect this example, while the paper supplies the proof.

Read about the theorem study →

Constructions & connections

Build a graph from smaller pieces

Cartesian products combine graphs; Cayley graphs turn group operations into edges. Hypercubes connect the two constructions. Their spectra make these relationships explicit.

Definitions and spectral formulas
Identity

Cartesian products add spectra

The vertices of G□HG\square H are pairs (u,v)(u,v). An edge changes exactly one coordinate along an edge of its factor. For simple, undirected graphs, the Laplacian is a Kronecker sum. Products of paths give grids; products of cycles give discrete tori.

LG□H=LG⊗IH+IG⊗LH,μij=λi(G)+λj(H).\begin{aligned} L_{G\square H}&=L_G\otimes I_H+I_G\otimes L_H,\\[4pt] \mu_{ij}&=\lambda_i(G)+\lambda_j(H). \end{aligned}
Proof / derivation

If LGui=λi(G)uiL_Gu_i=\lambda_i(G)u_i and LHvj=λj(H)vjL_Hv_j=\lambda_j(H)v_j, then ui⊗vju_i\otimes v_j is a product eigenvector with eigenvalue μij\mu_{ij}. These tensor products form a basis.

When both factors are connected and each has at least two vertices, the first positive sum is min⁡{λ2(G),λ2(H)}\min\{\lambda_2(G),\lambda_2(H)\}. Thus the slower factor determines the product's algebraic connectivity.

Fiedler (1973), property 3.4. Pairwise sums must be sorted to obtain the ordered spectrum.

Identity

Cyclic Cayley graphs turn symmetry into Fourier modes

On Zn\mathbb Z_n with n≥2n\geq2, choose S=−SS=-S excluding zero and connect xx to x+sx+s modulo nn. The controls add both signs of each step, counting the half-turn n/2n/2 once. This is the cyclic subfamily; Cayley graphs also exist on other groups.

χk(x)=e2πikx/n,μk=∣S∣−∑s∈Scos⁡ ⁣(2πksn),k=0,…,n−1.\chi_k(x)=e^{2\pi i kx/n},\qquad \mu_k=|S|-\sum_{s\in S}\cos\!\left(\frac{2\pi ks}{n}\right), \quad k=0,\ldots,n-1.
Proof / derivation

Translation multiplies χk\chi_k by a phase, giving adjacency eigenvalue ∑s∈Se2πiks/n\sum_{s\in S}e^{2\pi i ks/n}. Subtract from degree ∣S∣|S| and pair inverses to obtain the formula. These characters are one-dimensional group representations.

Paths reach the subgroup generated by SS. For nonempty SS, there are gcd⁡(n,{s:s∈S})\gcd(n,\{s:s\in S\}) components: the graph is connected when this is 1. An empty set gives nn isolated vertices.

Godsil, Duality, §3.2. Frequencies k are not sorted; the explorer orders eigenvalues numerically.

Identity

The hypercube belongs to both constructions

For d≥1d\geq1, the graph QdQ_d joins binary strings differing in one bit. It is both a Cartesian product of dd copies of K2K_2 and a Cayley graph on (Z2)d(\mathbb Z_2)^d, using the coordinate vectors as steps.

Qd=K2□⋯□K2⏟d factors,λ=2k with multiplicity (dk),0≤k≤d.Q_d=\underbrace{K_2\square\cdots\square K_2}_{d\text{ factors}}, \qquad \lambda=2k\ \text{with multiplicity}\ \binom{d}{k},\quad 0\leq k\leq d.
Proof / derivation

Each K2K_2 factor contributes either 0 or 2 to a product eigenvalue. Choosing the nonconstant mode in exactly kk coordinates gives 2k2k, in (dk)\binom{d}{k} ways.

Equivalently, the characters χa(x)=(−1)a⋅x\chi_a(x)=(-1)^{a\cdot x} are eigenvectors with eigenvalue 2∣a∣2|a|, where ∣a∣|a| counts the nonzero bits of aa. This identifies the product eigenbasis with the group characters.

Elementary product-spectrum consequence; see Pirazzini's Yale notes (2025), Example 6 and Theorem 8, for the Cayley interpretation.

Reading & interpretation

The graph editor uses simple, undirected, unweighted graphs. Values are computed numerically for the graph on screen; the tool does not search for a globally optimal graph. An eigenvector can change sign, and a repeated eigenvalue has many valid choices of eigenbasis. The colors therefore illustrate one choice of mode, rather than a unique partition.