Graph Theory: The Schoolboard Problem

A complete worked solution using adjacency matrices, matrix powers, and generating functions.

Original schoolboard with a four-vertex multigraph and four graph theory questions
Original schoolboard problem. Vertices 1, 2, and 4 form a triangle; vertices 2 and 3 are joined by two parallel edges.

Problem statement

Let \(G=(V,E)\) be the undirected multigraph shown above, with vertex set \(V=\{1,2,3,4\}\). Its edge multiset is \(E=\{\{1,2\},\{1,4\},\{2,4\},\{2,3\},\{2,3\}\}\). The two edges between vertices 2 and 3 are distinct, and therefore contribute a multiplicity of two.

  1. Find the adjacency matrix \(A\).
  2. Find the matrix giving the number of walks of length three.
  3. Find the generating function for walks from vertex \(i\) to vertex \(j\).
  4. Find the generating function for walks from vertex 1 to vertex 3.

1. The adjacency matrix

For an undirected multigraph, the adjacency matrix entry \(a_{ij}\) equals the number of edges joining vertices \(i\) and \(j\). The vertex ordering is \((1,2,3,4)\).

\[\boxed{A=\begin{pmatrix}0&1&0&1\\1&0&2&1\\0&2&0&0\\1&1&0&0\end{pmatrix}}\]

Because the graph is undirected, \(A=A^{\mathsf T}\). The diagonal entries are zero because there are no loops. The entries \(a_{23}=a_{32}=2\) account for the two parallel edges.

2. Matrix of three-step walks

A walk of length \(n\) is a sequence of \(n\) edges joining \(n+1\) vertices; vertices and edges may be revisited. The standard adjacency-matrix theorem states that

\[(A^n)_{ij}=\text{number of length-}n\text{ walks from }i\text{ to }j.\]

First, multiplying \(A\) by itself gives

\[A^2=\begin{pmatrix}2&1&2&1\\1&6&0&1\\2&0&4&2\\1&1&2&2\end{pmatrix}.\]

Multiplying once more yields the requested result:

\[\boxed{A^3=\begin{pmatrix}2&7&2&3\\7&2&12&7\\2&12&0&2\\3&7&2&2\end{pmatrix}}\]

For example, \((A^3)_{13}=2\): there are two length-three walks from vertex 1 to vertex 3. Both follow the vertex sequence \(1\to4\to2\to3\), but the final step can use either of the two parallel edges between 2 and 3. They are counted as distinct edge walks.

3. Generating function for walks from \(i\) to \(j\)

Let \(w_{ij}(n)=(A^n)_{ij}\) be the number of length-\(n\) walks from \(i\) to \(j\). Define the ordinary generating function

\[\boxed{G_{ij}(x)=\sum_{n=0}^{\infty}w_{ij}(n)x^n=\sum_{n=0}^{\infty}(A^n)_{ij}x^n.}\]

Collecting all vertex-pair generating functions into a matrix gives the matrix geometric series

\[G(x)=I+xA+x^2A^2+x^3A^3+\cdots.\]

Multiplication by \(I-xA\) produces the identity matrix, so as a formal power series (or analytically for sufficiently small \(|x|\)):

\[\boxed{G(x)=(I-xA)^{-1},\qquad G_{ij}(x)=\bigl[(I-xA)^{-1}\bigr]_{ij}.}\]

Here

\[I-xA=\begin{pmatrix}1&-x&0&-x\\-x&1&-2x&-x\\0&-2x&1&0\\-x&-x&0&1\end{pmatrix}.\]

The determinant is

\[\det(I-xA)=1-7x^2-2x^3+4x^4=(1+x)(1-x-6x^2+4x^3).\]

4. Generating function for walks from 1 to 3

We require the entry in row 1, column 3 of \((I-xA)^{-1}\). Using the adjugate formula,

\[(M^{-1})_{13}=\frac{C_{31}(M)}{\det M},\qquad M=I-xA,\]

where \(C_{31}(M)\) is the cofactor of the entry in row 3, column 1. Direct evaluation gives

\[C_{31}(M)=2x^2(1+x).\]

Therefore,

\[G_{13}(x)=\frac{2x^2(1+x)}{1-7x^2-2x^3+4x^4}.\]

Canceling the common factor \((1+x)\) gives the simplified closed form:

\[\boxed{G_{13}(x)=\frac{2x^2}{1-x-6x^2+4x^3}.}\]

Power-series verification

Expanding about \(x=0\),

\[\boxed{G_{13}(x)=2x^2+2x^3+14x^4+18x^5+94x^6+146x^7+638x^8+\cdots.}\]

The coefficient of \(x^n\) is exactly the number of length-\(n\) walks from vertex 1 to vertex 3. In particular, the coefficient of \(x^3\) is 2, matching the \((1,3)\) entry of \(A^3\).

Recurrence relation

Writing \(G_{13}(x)=\sum_{n\ge0}a_nx^n\), the denominator of the simplified rational function implies

\[a_n=a_{n-1}+6a_{n-2}-4a_{n-3}\qquad(n\ge3),\]

with \(a_0=0,\ a_1=0,\ a_2=2\). Thus \(a_3=2\), \(a_4=14\), and so on.

Final answers

\[\boxed{A=\begin{pmatrix}0&1&0&1\\1&0&2&1\\0&2&0&0\\1&1&0&0\end{pmatrix}}\]
\[\boxed{A^3=\begin{pmatrix}2&7&2&3\\7&2&12&7\\2&12&0&2\\3&7&2&2\end{pmatrix}}\]
\[\boxed{G_{ij}(x)=\bigl[(I-xA)^{-1}\bigr]_{ij}}\]
\[\boxed{G_{13}(x)=\frac{2x^2}{1-x-6x^2+4x^3}}\]
Mathematical convention: The generating functions count walks, not simple paths. Distinct parallel edges are counted separately. The inverse-matrix identity is valid as a formal power series without requiring numerical convergence.