Ben Lu

benlu2267[at]gmail.com

← Writing

How to draw a graph

June 22, 2026

This entry was last updated on August 9th, 2026

For any representation of a graph GG in Rk\mathbb{R}^k, we can imagine a mapping

ρ:V(G)Rk\rho : V(G) \to \mathbb{R}^k

which assigns each vertex of GG a position. Since we are dealing with a finite number of points in GG, we can represent ρ\rho with a matrix RR.

R:=[ρ(v1)ρ(v2)ρ(vn)]Rn×kR := \begin{bmatrix} \rule[0.5ex]{2.5em}{0.4pt} & \rho(v_1)^\top & \rule[0.5ex]{2.5em}{0.4pt} \\ \rule[0.5ex]{2.5em}{0.4pt} & \rho(v_2)^\top & \rule[0.5ex]{2.5em}{0.4pt} \\ & \vdots & \\ \rule[0.5ex]{2.5em}{0.4pt} & \rho(v_n)^\top & \rule[0.5ex]{2.5em}{0.4pt} \\ \end{bmatrix} \in \mathbb{R}^{n \times k}

We call ρ\rho balanced iff 1R=0\mathbf{1}^\top R = 0. In English, this just means averaging the position of the vertices gives the origin. Informally, we can always translate our graph so the "middle" is on the origin, we can assume all representations we'll work with are balanced. We can also assume that the columns of the matrix are linearly independent, since otherwise we are looking at some lower dimensional subspace, and we could just look at Rlowerdim\mathbb{R}^{lower dim}.

It's natural to place our vertices where R tells us to and imagine our edges are springs, then check the "stretching" of strings between vertices. We will want to minimize this stretching for a "good" drawing, but also ignore having 0 distance between vertices, as it's (obviously) not a very impressive drawing although it minimizes energy.

To capture the amount of stretching lets define the energy of ρ\rho

E(R)={u,v}E(G)ρ(u)ρ(v)2,\mathcal{E}(R) = \sum_{\{u,v\} \in E(G)} \left\lVert \rho(u) - \rho(v) \right\rVert^2,

where \lVert \cdot \rVert is the Euclidean norm. If we want to allow some springs to matter more than others, we can introduce a weight function

w:E(G)R w: E(G) \to \mathbb{R}

that assigns a weight to each edge uv \in E(G).

So we end up with the updated energy function

E(R)={u,v}E(G)w(uv)ρ(u)ρ(v)2.\mathcal{E}(R) = \sum_{\{u,v\} \in E(G)} w(uv) \left\lVert \rho(u) - \rho(v) \right\rVert^2.

Some expansion and book-keeping verifies the following.

Lemma. The energy is a Laplacian quadratic form,

E(R)=tr(RLR),\mathcal{E}(R) = \operatorname{tr}(R^\top L R),

where L=DWL = D - W, the weighted degree matrix minus the weighted adjacency matrix, finally bringing out the familiar (weighted) Laplacian.

This identity gives us our main result.

Theorem. Let GG be a connected graph of order nn (given by λ2>0\lambda_2 > 0) with weighted Laplacian LL. If λ1λ2λn\lambda_1 \le \lambda_2 \le \cdots \le \lambda_n are the eigenvalues of LL, then the minimum energy of a balanced, orthogonal representation ρ\rho of GG in Rk\mathbb{R}^k is

minE(R)=i=2k+1λi.\min \mathcal{E}(R) = \sum_{i=2}^{k+1} \lambda_i.

Proof Sketch. By the lemma we're minimizing tr(RLR)\operatorname{tr}(R^\top L R), and for any orthogonal representation this is at least the sum of the smallest that many eigenvalues of LL.

Since the rows of LL sum to zero, 1\mathbf{1} is the eigenvector for λ1=0\lambda_1 = 0, so gluing it onto a balanced RRkR \in \mathbb{R}^k as an extra column costs 0 energy and hands us a Rk+1\mathbb{R}^{k+1} representation forcing E(R)λ2++λk+1\mathcal{E}(R) \ge \lambda_2 + \cdots + \lambda_{k+1}. Similarly, we can add a 1\mathbf{1} vector to a minimum representation in Rk1\mathbb{R}^{k-1} to get a representation in Rk\mathbb{R}^k with equal energy. \blacksquare

If we are drawing a graph on paper or something like R2\mathbb{R^2}, this is λ2+λ3\lambda_2 + \lambda_3. Finally, this yields our algorithm given a graph G:

  1. Compute the two smallest non-zero eigenvalues λ2λ3\lambda_2 \leq \lambda_3 of the weighted Laplacian.

  2. Compute eigenvectors u2u_{2}' and u3u_{3}' for λ2λ3\lambda_2 \leq \lambda_3, and normalize to get the unit eigenvectors u2u_2 and u3u_3.

  3. This gives R:=[u2,u3]R := [u_2, u_3], where each pair (u2i,u3i)(u_{2i}, u_{3i}) is a coordinate to be plotted to give drawing.

Example:

10.057λ₂ + λ₃ = 4.443

2.26× minimum

Source

C. Godsil and G. Royle, Algebraic Graph Theory, Graduate Texts in Mathematics 207, Springer, 2001.