Skip to content

Graphs and networks

Write a network as an incidence matrix, read potentials and currents as vectors, and find Kirchhoff’s laws in its four subspaces.

Helps to know first
This topic

First, the picture

Five wires join four points. Watch current circle round each loop while every junction stays in balance.

Kirchhoff's laws are linear algebra

Current round a loop: in equals out at every node.

Four nodes and five edges, each edge with a number and an arrow.

edge currents y
–
in − out at the nodes
–
0.00 / 12.80 s
Describe this picture

A small network of four numbered nodes, drawn as a diamond: node 1 on the left, 2 at the top, 3 on the right, 4 at the bottom. Five numbered edges join them, each with an arrow: edge 1 from node 1 to 2, edge 2 from 2 to 3, edge 3 from 1 to 3 straight across, edge 4 from 1 to 4, edge 5 from 3 to 4. A unit current circulates round the loop 1 to 2 to 3 and back to 1, drawn as dots running along the lit edges, and each lit edge is labelled with its value: +1+1 on edges 1 and 2, and −1-1 on edge 3, where the current runs against the arrow. Readouts give the edge values as a vector, y=(1,1,−1,0,0)\mathbf{y}=(1,1,-1,0,0), and the total current in minus out at the nodes, (0,0,0,0)(0,0,0,0), which is also written beside every node. Then a second unit current circulates round the loop 1 to 3 to 4 and back to 1, with edge values (0,0,1,−1,1)(0,0,1,-1,1), and every node total is still 0. There is no control.

A small network

A graph is a set of points, the nodes, joined by lines, the edges. The picture has 4 nodes and 5 edges. Think of the edges as wires, pipes or roads, and the nodes as the junctions where they meet.

Each edge gets an arrow, chosen once and never changed. The arrow does not say which way anything flows. It only fixes a sign: a flow along the arrow counts as positive, and a flow against it as negative. The first loop in the picture runs against the arrow of edge 3, so edge 3 gets −1-1.

The incidence matrix

Write the graph as a matrix with one row per edge and one column per node. In each row, put −1-1 in the column of the node the edge leaves, +1+1 in the column of the node it enters, and 0 elsewhere. This is the incidence matrix:

A=[−11000−110−1010−100100−11].\mathbf{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}.

Row 1 is edge 1, from node 1 to node 2; row 5 is edge 5, from node 3 to node 4. With m=5m=5 edges and n=4n=4 nodes, A\mathbf{A} is 5×45\times4.

Potentials in, differences out

Give each node a number xqx_q, its potential: a voltage in a circuit, a pressure in pipes, a height in a landscape. The vector x\mathbf{x} has one entry per node, so it is an input of A\mathbf{A}. Each row of Ax\mathbf{A}\mathbf{x} is the potential at the head of an edge minus the potential at its tail:

Ax=[x2−x1x3−x2x3−x1x4−x1x4−x3].\mathbf{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}.

With potentials x=(0,1,3,4)\mathbf{x}=(0,1,3,4) the differences are (1,2,3,4,1)(1,2,3,4,1).

What does A\mathbf{A} erase? Only differences reach the output, so raising every potential by the same amount changes nothing. The null space is the line of (1,1,1,1)(1,1,1,1): equal potentials, no differences, nothing flows. For a graph in one connected piece, that is the whole null space, so dim⁡N(A)=1\dim N(\mathbf{A})=1 and the rank is r=n−1=3r=n-1=3.

Loops

Now put a current yky_k on each edge, positive along its arrow. The vector y\mathbf{y} has one entry per edge, so it lives on the output side of A\mathbf{A}.

Multiply by the transpose. Column qq of A\mathbf{A} has +1+1 for the edges that enter node qq and −1-1 for those that leave it, so entry qq of A⊤y\mathbf{A}^\top\mathbf{y} is the current flowing into node qq minus the current flowing out. Kirchhoff’s current law says that, with nothing fed in from outside, these are equal at every node:

A⊤y=0.\mathbf{A}^\top\mathbf{y}=\mathbf{0}.

So the currents that can flow on their own are exactly the left null space N(A⊤)N(\mathbf{A}^\top), from The four fundamental subspaces. Its dimension is m−r=5−3=2m-r=5-3=2, and the two loop currents of the picture are a basis: (1,1,−1,0,0)(1,1,-1,0,0) round nodes 1, 2, 3, and (0,0,1,−1,1)(0,0,1,-1,1) round nodes 1, 3, 4. Every current that balances at every node is a mix of these two loops.

The same vectors carry the other law. Read (1,1,−1,0,0)(1,1,-1,0,0) as weights on the rows: row 1 plus row 2 minus row 3 is the zero row. So for any potentials, the differences round that loop add up to zero: here 1+2−3=01+2-3=0. That is Kirchhoff’s voltage law. It is the right angle of the four subspaces page: a left null vector is perpendicular to every output Ax\mathbf{A}\mathbf{x}.

Counting

Put the two dimensions together. The null space gives r=n−1r=n-1, and the loops are m−rm-r of them:

loops=m−r=m−(n−1).\text{loops}=m-r=m-(n-1).

Rearranged, this is Euler’s count for a connected graph:

(nodes)−(edges)+(loops)=1.(\text{nodes})-(\text{edges})+(\text{loops})=1.

Here 4−5+2=14-5+2=1. Add a sixth edge and you add one loop; add a node with one edge to reach it and you add no loop.

A resistor network

Make every edge a resistor. Its conductance gkg_k is one over its resistance, in siemens, and the matrix G=diag(g1,…,g5)\mathbf{G}=\mathrm{diag}(g_1,\dots,g_5) holds them on its diagonal.

Current flows from high potential to low, and Ohm’s law says how much: conductance times the drop. Measured along the edge arrows, the drop is tail minus head, which is −Ax-\mathbf{A}\mathbf{x}. So on this page

y=−GAx.\mathbf{y}=-\mathbf{G}\mathbf{A}\mathbf{x}.

Now feed currents in from outside, bqb_q amperes into node qq. At each node, what flows out along the edges equals what is fed in. Flow out is −A⊤y-\mathbf{A}^\top\mathbf{y}, so −A⊤y=b-\mathbf{A}^\top\mathbf{y}=\mathbf{b}, and with Ohm’s law:

A⊤GA x=b.\mathbf{A}^\top\mathbf{G}\mathbf{A}\,\mathbf{x}=\mathbf{b}.

The matrix K=A⊤GA\mathbf{K}=\mathbf{A}^\top\mathbf{G}\mathbf{A} is n×nn\times n, one row per node. It has the same null space as A\mathbf{A}: raising every potential changes no current. So fix one potential first, which an engineer calls grounding a node: set its potential to 0, and drop its row and column.

With every resistor 1 Ω, G=I\mathbf{G}=\mathbf{I} and K=A⊤A\mathbf{K}=\mathbf{A}^\top\mathbf{A}:

K=[3−1−1−1−12−10−1−13−1−10−12].\mathbf{K}=\begin{bmatrix}3&-1&-1&-1\\-1&2&-1&0\\-1&-1&3&-1\\-1&0&-1&2\end{bmatrix}.

Each diagonal entry counts the edges at a node, and each −1-1 marks a pair of nodes joined by an edge.

Worked example

Feed 1 A into node 1 and take it out at node 4, which is grounded: x4=0x_4=0. So b=(1,0,0)\mathbf{b}=(1,0,0) for nodes 1 to 3. Drop row and column 4 of K\mathbf{K}:

3x1−x2−x3=1,−x1+2x2−x3=0,−x1−x2+3x3=0.\begin{aligned} 3x_1-x_2-x_3&=1,\\ -x_1+2x_2-x_3&=0,\\ -x_1-x_2+3x_3&=0. \end{aligned}

The solution is x1=0.625x_1=0.625, x2=0.5x_2=0.5 and x3=0.375x_3=0.375 volts. The currents along the arrows are then

y=−Ax=[0.1250.1250.250.6250.375] A.\mathbf{y}=-\mathbf{A}\mathbf{x}=\begin{bmatrix}0.125\\0.125\\0.25\\0.625\\0.375\end{bmatrix}\,\text{A}.

Check each node:

  • Node 1: edges 1, 3 and 4 leave it, carrying 0.125+0.25+0.625=10.125+0.25+0.625=1 A, the current fed in.
  • Node 2: 0.125 A arrives on edge 1 and leaves on edge 2.
  • Node 3: 0.125+0.25=0.3750.125+0.25=0.375 A arrives on edges 2 and 3 and leaves on edge 5.
  • Node 4: 0.625+0.375=10.625+0.375=1 A arrives, and leaves through the ground.

Node 1 sits at 0.625 V while 1 A flows to node 4, so the network behaves like a single resistor of 0.625 Ω0.625\,\Omega between those two nodes. Most of the current, 0.625 A, takes the direct edge 4.

Predict before you check: by which edge does most current leave node 1? Edge 4, the direct one.

Where you’ll meet this

Circuit simulators. A simulator reads a list of components and the nodes they join, builds A⊤GA\mathbf{A}^\top\mathbf{G}\mathbf{A} from it, grounds one node and solves for every potential. This is called nodal analysis, and it is the matrix of this page, built from a list instead of by hand.

Pipes, roads and power grids. Water in pipes, cars on roads and power on a grid obey the same two laws: what enters a junction leaves it, and a flow is driven by a difference in pressure, demand or voltage. The same matrix appears with new names for x\mathbf{x} and y\mathbf{y}.

Grouping points. With unit conductances, A⊤A\mathbf{A}^\top\mathbf{A} is called the graph Laplacian. Methods that sort the members of a network into tightly linked groups, such as communities of friends, start from it.

Reference card

QuantityFormulaNotes
Incidence matrixA\mathbf{A}, m×nm\times none row per edge: −1-1 at the tail, +1+1 at the head
DifferencesAx\mathbf{A}\mathbf{x}head minus tail potential, per edge
Null spacethe line of (1,…,1)(1,\dots,1)equal potentials; r=n−1r=n-1 for a connected graph
Current lawA⊤y=0\mathbf{A}^\top\mathbf{y}=\mathbf{0}balanced currents form N(A⊤)N(\mathbf{A}^\top), the loops
Voltage lawloop vector ⋅ Ax=0\cdot\,\mathbf{A}\mathbf{x}=0differences round a loop add to zero
Euler’s countnodes −- edges ++ loops =1=1connected graph
Ohm’s lawy=−GAx\mathbf{y}=-\mathbf{G}\mathbf{A}\mathbf{x}current along the arrows, high to low potential
Network equationA⊤GA x=b\mathbf{A}^\top\mathbf{G}\mathbf{A}\,\mathbf{x}=\mathbf{b}b\mathbf{b} is the current fed in; ground one node first

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look