Session 12 · Unit 1

Graphs, Networks, Incidence Matrices


Real matrices come from applications, and the best source is a graph. The incidence matrix of a graph carries all its structure, and the four fundamental subspaces turn out to say physical things: the null space is constant potentials, the null space of A transpose is Kirchhoff's Current Law, loops are dependencies, trees are independence — and counting dimensions proves Euler's formula.

Matrices that come from somewhere

Strang opens with a confession. When he needs an example of a null space or a row space, he invents a little matrix on the spot — and he feels a little guilty about it, “because the truth is that real linear algebra uses matrices that come from somewhere.” They come from applications, they have definite structure, and everyone who works with them uses that structure. Chemistry professors row-reduce matrices that record how many molecules of each kind go into a reaction and what comes out. The people at Mathworks build Matlab around exactly these computations.

So today’s lecture is about what Strang calls “the most important model in applied math” — and its discrete version is a graph. A graph is a source of matrices, and the matrix it produces is the star of this lecture.

A graph and its incidence matrix

A graph has nodes and edges. Strang draws a small one: n=4n = 4 nodes and m=5m = 5 edges. Edge 1 runs from node 1 to node 2, edge 2 from node 2 to node 3, edge 3 from node 1 to node 3, edge 4 from node 1 to node 4, and edge 5 from node 3 to node 4. Each edge gets an arrow — a direction, chosen arbitrarily — so that a current flowing along it counts as positive with the arrow and negative against it. (Real interest would be in the graph of all websites, or all telephones, or all people in the world; four nodes is enough to see everything.)

The language will be electrical — potentials, potential differences, currents — but the same picture describes a hydraulic network carrying water or oil, or a structure like a bridge or a Buckminster Fuller dome.

For Strang’s graph, with five edges and four nodes:

A=[11000110101010010011]A = \begin{bmatrix} -1 & 1 & 0 & 0 \\ 0 & -1 & 1 & 0 \\ -1 & 0 & 1 & 0 \\ -1 & 0 & 0 & 1 \\ 0 & 0 & -1 & 1 \end{bmatrix}

A big graph would give a big matrix — but a very sparse one: every row has exactly two nonzeros, so the number of nonzeros is exactly 2m2m. That is structure, and it can be used.

Notice something already. Edges 1, 2, 3 form a loop in the graph — and look at rows 1, 2, 3 of AA: row 1 plus row 2 equals row 3. Loops correspond to linearly dependent rows. Hold that thought.

The null space of A: potentials up to a constant

First question, always: what is the null space? Are the four columns independent? Solve Ax=0A\mathbf{x} = \mathbf{0} with x=(x1,x2,x3,x4)\mathbf{x} = (x_1, x_2, x_3, x_4):

Ax=[x2x1x3x2x3x1x4x1x4x3]A\mathbf{x} = \begin{bmatrix} x_2 - x_1 \\ x_3 - x_2 \\ x_3 - x_1 \\ x_4 - x_1 \\ x_4 - x_3 \end{bmatrix}

The matrix we built computes differences across every edge. Interpret x\mathbf{x} as potentials at the nodes; then AxA\mathbf{x} gives the potential differences across the edges. When are all five differences zero? When all the potentials are equal:

x=c[1111]\mathbf{x} = c\begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bmatrix}

So the null space is one-dimensional — the line through (1,1,1,1)(1, 1, 1, 1) — and the rank is r=n1=3r = n - 1 = 3. Any three columns of AA are independent.

Physically: the potentials can only be determined up to a constant. Potential differences are what make current flow; if all potentials equal cc, nothing moves. It’s the same arbitrary constant as ranking football teams, or measuring temperature in Celsius versus from absolute zero, or the +c+c in every indefinite integral from calculus. The standard fix is to ground a node — set its potential to zero. That removes one column, the remaining three are independent, and all other potentials can then be computed.

The null space of A transpose: Kirchhoff’s Current Law

Now the equation Strang calls “probably the most fundamental equation of applied mathematics”: ATy=0A^T\mathbf{y} = \mathbf{0}. Here ATA^T is 4×54 \times 5, and y=(y1,,y5)\mathbf{y} = (y_1, \ldots, y_5) holds the currents on the edges.

Its dimension we know in advance: dimN(AT)=mr=53=2\dim N(A^T) = m - r = 5 - 3 = 2.

But what does the equation say? Write out the rows of ATy=0A^T\mathbf{y} = \mathbf{0}:

y1y3y4=0y1y2=0y2+y3y5=0y4+y5=0\begin{aligned} -y_1 - y_3 - y_4 &= 0 \\ y_1 - y_2 &= 0 \\ y_2 + y_3 - y_5 &= 0 \\ y_4 + y_5 &= 0 \end{aligned}

Each equation belongs to a node. The first says the net current leaving node 1 is zero — edges 1, 3, 4 all leave node 1, so y1+y3+y4=0y_1 + y_3 + y_4 = 0. The second says y1=y2y_1 = y_2: current in equals current out at node 2. This is Kirchhoff’s Current Law: a balance equation, a conservation law. Charge doesn’t accumulate at the nodes; it travels around.

Trees and Euler’s formula

What about the row space of AA — the column space of ATA^T? Its dimension is the rank, 3. But the first three columns of ATA^T are not a basis: they correspond to edges 1, 2, 3, which form a loop, and the loop vector in N(AT)N(A^T) says column 1 plus column 2 equals column 3. The pivot columns are 1, 2, and 4 — edges 1, 2, 4, which form a subgraph with the same four nodes, three edges, and no loop. The independent edges are exactly the ones without a loop.

Now look once more at the dimension formula dimN(AT)=mr\dim N(A^T) = m - r, and read every symbol off the graph. The dimension of N(AT)N(A^T) is the number of independent loops. mm is the number of edges. And r=n1r = n - 1: the rank is the number of nodes minus one, because of the vector (1,1,1,1)(1, 1, 1, 1) in the null space. So the number of loops equals m(n1)m - (n - 1), and rearranging:

Check it on the lecture’s graph: 45+2=14 - 5 + 2 = 1. Strang draws a messier graph with five nodes, seven edges, three loops: 57+3=15 - 7 + 3 = 1. “And Euler’s right, I always get one.” Euler’s formula is a great fact of topology, true for any graph — and linear algebra proves it, just by computing the dimension of N(AT)N(A^T) two ways. “We see Euler again — that guy never stopped.”

The framework of applied mathematics

The lecture closes with the picture Strang calls the great picture of applied mathematics, built from three steps.

Start with the potentials x\mathbf{x} at the nodes. First, AA computes potential differences across the edges:

e=Ax\mathbf{e} = A\mathbf{x}

Second, Ohm’s Law: the current on an edge is a number — the conductance, one over the resistance — times the potential drop. A diagonal matrix CC of physical constants connects them:

y=Ce\mathbf{y} = C\mathbf{e}

Third, Kirchhoff’s Current Law balances the currents at the nodes. With no outside source, ATy=0A^T\mathbf{y} = \mathbf{0}. To make something actually happen, add external current sources f\mathbf{f} going into and out of the nodes (batteries in the edges are the other option), and KCL becomes ATy=fA^T\mathbf{y} = \mathbf{f}.

Chain the three steps together — multiply by AA, then CC, then ATA^T — and you get the basic equation of applied math in equilibrium (no time, no Newton’s law; everything has settled down):

ATCAx=fA^T C A\,\mathbf{x} = \mathbf{f}

Rectangular matrices came from the real application, but they arrive together with their transposes — which is exactly why the four subspaces are the right things to know. Strang’s final question: what can you say about the matrix ATCAA^T C A, or even ATAA^T A? It is always symmetric.

Problems

Work these before revealing the solutions — everything you need is in the lecture.

Problem 12.1 Building an incidence matrix

A directed graph has 3 nodes and 3 edges: edge 1 from node 1 to node 2, edge 2 from node 2 to node 3, edge 3 from node 1 to node 3. Write the incidence matrix AA, find its rank, and give a basis for N(A)N(A). Which rows are dependent, and why does the graph tell you so before any elimination?

Show solution
A=[110011101]A = \begin{bmatrix} -1 & 1 & 0 \\ 0 & -1 & 1 \\ -1 & 0 & 1 \end{bmatrix}

Ax=(x2x1, x3x2, x3x1)A\mathbf{x} = (x_2 - x_1,\ x_3 - x_2,\ x_3 - x_1), which is zero exactly when x1=x2=x3x_1 = x_2 = x_3. So N(A)N(A) has basis (1,1,1)(1, 1, 1), its dimension is 1, and the rank is r=n1=2r = n - 1 = 2.

The three edges form a loop, so the rows must be dependent: row 1 plus row 2 equals row 3. One loop, and indeed mr=32=1m - r = 3 - 2 = 1 dependency.

Problem 12.2 Kirchhoff by thinking, not eliminating

A directed graph has 4 nodes and 5 edges: edge 1 from node 1 to node 2, edge 2 from node 2 to node 3, edge 3 from node 3 to node 4, edge 4 from node 4 to node 1, and edge 5 from node 1 to node 3 (a diagonal). Without elimination, find the dimension of N(AT)N(A^T) and write down a basis of loop currents. Then express the current around the outer loop (edges 1, 2, 3, 4) in terms of your basis.

Show solution

Here n=4n = 4, m=5m = 5, so r=n1=3r = n - 1 = 3 and dimN(AT)=mr=53=2\dim N(A^T) = m - r = 5 - 3 = 2: two independent loops.

Loop A uses edges 1, 2, 5: one amp along edge 1, then edge 2, returning against edge 5’s arrow gives

yA=(1,1,0,0,1)\mathbf{y}_A = (1, 1, 0, 0, -1)

Loop B uses edges 5, 3, 4: one amp with edge 5, then edges 3 and 4, gives

yB=(0,0,1,1,1)\mathbf{y}_B = (0, 0, 1, 1, 1)

Both satisfy current balance at every node.

The outer loop sends one amp along edges 1, 2, 3, 4: (1,1,1,1,0)(1, 1, 1, 1, 0). That is exactly yA+yB\mathbf{y}_A + \mathbf{y}_B — the currents on the shared diagonal edge 5 cancel, so the outer loop is dependent, not a third basis vector.

Problem 12.3 Euler's formula as dimension count

A connected graph has 6 nodes and 9 edges. (a) What is the rank of its incidence matrix AA? (b) What is dimN(AT)\dim N(A^T), and how many independent loops does the graph have? (c) How many edges must you remove to leave a tree, and how many edges does that tree have?

Show solution

(a) The rank is r=n1=5r = n - 1 = 5: the only dependency among the columns is the constant vector (1,,1)(1, \ldots, 1) in N(A)N(A).

(b) dimN(AT)=mr=95=4\dim N(A^T) = m - r = 9 - 5 = 4, so there are 4 independent loops. Check with Euler: nodes - edges ++ loops =69+4=1= 6 - 9 + 4 = 1. ✓

(c) A tree has no loops, so removing one well-chosen edge per independent loop — 4 edges — leaves a tree with 94=59 - 4 = 5 edges. That matches the general fact: a tree on nn nodes has n1n - 1 edges, exactly the rank of AA.

Problem 12.4 The symmetric product

Let AA be any m×nm \times n incidence matrix and CC a diagonal matrix of positive conductances. (a) Show that K=ATCAK = A^T C A is symmetric. (b) For the 3-node loop graph of Problem 12.1 with C=IC = I, compute ATAA^T A and identify the vector in its null space. What does that mean for solving ATCAx=fA^T C A\,\mathbf{x} = \mathbf{f}?

Show solution

(a) Transpose the product, reversing the order: KT=(ATCA)T=ATCT(AT)T=ATCA=KK^T = (A^T C A)^T = A^T C^T (A^T)^T = A^T C A = K, since the diagonal matrix satisfies CT=CC^T = C. So KK is symmetric — always.

(b) With AA from Problem 12.1:

ATA=[211121112]A^T A = \begin{bmatrix} 2 & -1 & -1 \\ -1 & 2 & -1 \\ -1 & -1 & 2 \end{bmatrix}

Each row sums to zero, so (1,1,1)(1, 1, 1) is in the null space of ATAA^T A — the same constant vector that was in N(A)N(A). The matrix is singular, which says the potentials are only determined up to a constant. To solve ATCAx=fA^T C A\,\mathbf{x} = \mathbf{f} in practice, ground a node: fix one potential at zero, delete that row and column, and the remaining system is invertible.