Graph and Matrices
Graph and Matrices
Takis Konstantopoulos
February 2000
1 Introduction
This is a set of notes I wrote while teaching courses in circuit theory for undergraduate electrical engineering
students. They can be read in connection with any good standard book on the subject. They basically contain
the essence of a large chunk of a circuit theory course. Circuit theory is, of course, obtained by making an
idealization of Maxwells equations in the absence of charges and when we can ignore magnetic fields. From
a mathematical point of view, circuit theory can be seen as a topic in graph theory, a topic in linear algebra,
but also a topic in discrete harmonic analysis. The benign set of Kirchoffs laws and Ohms laws, familiar to
any electrical engineer, in other words a mere set of linear equations, contains, in disguise, a lot of physical
and mathematical beauty. The point of the notes is to first explain why a circuit can be solved, and, second,
present the standard methods for doing so (variants of which exist in common software packages for circuit
simulation).
The first thing we do here is to identify the graph of the circuit. That is, we identify the set of vertices V , and
the set of edges E. The graph is G = (V,E). Next, each edge is given an arbitrary orientation. If the edge
between vertices k and ` is considered unoriented, it is denoted by {k, `}. If it is oriented it is designated as
(k, `), where k is the start-vertex and ` is the end-vertex. For example, here is a circuit and its graph.
+
_
_
__
__
_ __
_ ______
__
__
__
__
__
__
__
__
__
1 2 __3
5
e
e
e
e
e
e
e
e
2
4
3
5
7
6
8
1
2
4
3
6
R
R
R
V
1
5
R
R
R
8
__
__
__
__
__
__
__
__
__
__
______
_
_
_
_
_
_
_
_
_____
1____2_ 3
654
Figure 2: A NON-PLANAR GRAPH
The nice thing about graphs, is that they contain the minimal information about the topological structure
of the circuit, which is responsible for the writing of the two circuit laws: Kirchhoffs Current Law (KCL)
and Kirchhoffs Voltage Law (KVL). It is often nice and pleasing to reduce a model into its bare minimum
so we can see exactly how much we can say about it, without getting confused by redundant information.
A current configuration, or simply current, for a graph G = (V,E) is a collection i = (ie, e 2 E) of numbers
ie associated to edges e so that they satisfy KCL. That is, for each vertex k look at all edges e incident to k,
let bk,e be +1 is k is a start-vertex of e or 1 if k is an end-vertex of e and write
X
e
bk,eie = 0. (1)
If we define bk,e to be 0 if e is not incident to vertex k, then the above summation can be extended over all
e 2 E.
Next, we turn to KVL. A cycle (or loop) ` of G is a collection of distinct vertices k1, . . . , kj , such that
{k1, k2}, {k2, k3}, . . . , {kj1, kj}, {kj , k1} are all edges of the unoriented graph. The cycle orientation of
cycle ` is the orientation at which we traverse its vertices. The actual orientation of a particular edge e of
` may or may not agree with that of `. We define numbers a`,e as follows: if e does not belong to cycle `
then a`,e = 0; if e belongs to ` and e has the same orientation as `, then ae = +1; otherwise, ae = 1. A
voltage configuration v = (ve, e 2 E) is an assignment of numbers ve to the edges e of G in a way that KVL
is satisfied. KVL, for a given cycle `, says that
X
e
a`,eve = 0. (2)
We can encode KCL by using the language of matrices. For this purpose, we define the incidence matrix B
of the graph G = (V,E) (whose edges have been given an arbitrary orientation) as a matrix whose rows are
2
indexed by vertices and columns by edges. The entry of B corresponding to row (vertex) k and column (edge)
e is simply taken to be bk,e as defined above. For instance, in the first example, we have
B=
0
BBBB@
0 1 1 1 0 0 0 0
0 0 0 1 1 1 0 0
1 0 1 0 1 0 1 0
1 0 0 0 0 0 0 1
0 1 0 0 0 1 1 1
1
CCCCA
1
2
3
4
5
e1 e2 e3 e4 e5 e6 e7 e8
Thus, column 3 of B has 1 at position 3 and 1 at position 1, meaning that edge e3 starts at vertex 3 and
ends at vertex 1. If we thus let i = (i1, i2, i3, i4, i5, i6, i7, i8)T be a column of a current configuration, we can
encode KCL as follows:
Bi = 0. (3)
Indeed, if, e.g., we multiply the second row of B by i we get i4 + i5 + i6 = 0, which is KCL at vertex 2.
We can encode KVL (1) by introducing the cycle matrix A, whose rows are indexed by oriented cycles
and columns by oriented edges, and whose typical element, corresponding to row (cycle) ` and column (edge)
e is a`,e, as defined above. For instance, in the example of Fig. 1, we have the cycles (1, 2, 5), (2, 3, 4, 5), etc.
There are too many cycles, so Im not going to list them all. The cycle matrix is
A=
0
@
01010100
1 0 0 0 1 1 0 1
......................................
1
A
cycle (1,2,5)
cycle (2,3,4,5)
e1 e2 e3 e4 e5 e6 e7 e8
Again, I only listed its first two rows, corresponding to the cycles (1, 2, 5) and (2, 3, 4, 5). KVL (2) now reads
Av = 0. (4)
So, with the identification of a graph and the introduction of the matrices B and A, we managed to encode
the relevant information of the circuit and express KCL and KVL in the form of (3) and (4). Let us see what
we can say about these two laws, before we introduce any additional constraints, i.e., before we take into
account the actual identity of the circuit elements sitting at the various branches of the circuit.
A WORD ON NOTATION: Suppose that A is a m n matrix. We will use AT to denote the transpose of
A, i.e. the n m matrix whose rows are the columns of A. If B is another n k matrix then the rule for the
transpose of the product says that (AB)T = BTAT. The set all n-vectors x such that Ax = 0 is denoted by
N(A):
N(A) := {x : Ax = 0}.
The set of all m-vectors y such that y = Ax for some vector n-vector x is denoted by R(A):
R(A) := {y : y = Ax for some x}.
Note then, that every such y is a linear combination of the columns of A. In other words, R(A) contains all
linear combinations of the columns of A. In the same vein, the set containing all linear combinations of the
rows of A is denoted by R(AT) (because rows of A are columns of AT).
solving circuits, it will tell us what energy conservation actually means, and it will essentially exhaust the
study of circuits.
First, observe that every row of A (i.e. every cycle vector) is a valid current configuration, i.e., that every
row of A satisfies (3). To see this, consider a vertex k and a loop `. Either k does not belong to `, in which
case the contribution of ` to the KCL at k is zero, or k belongs to `; in the latter case, there are two edges in
` Fig. to k, one ending at k and one starting at k; Hence the contribution of ` to the KCL at k is 1 + 1 = 0.
In matrix notation,
BAT = 0. (5)
A consequence of (5) is that the cycle space is contained in the current space:
CYCL-SP _ CURR-SP . (6)
Indeed, a vector in the cycle space is, by definition, of the form ATx. But then B(ATx) = 0. So ATx is also
in the current space. Now we can take transpose in (5) to get
ABT = 0, (7)
which means that the node space is contained in the voltage space:
VERT-SP _ VOLT-SP . (8)
In fact, we claim that the opposite inclusions in (6) and (8) also hold. To show this, we need a bit more of
graph theory.
Assume that the graph is connected (the general case follows easily), with n vertices and m edges. Since
every vertex is connected by an edge to some other vertex, we have
m _ n 1.
A tree is a connected graph that has no cycles at all. A spanning tree of G is a tree that contains all the
vertices of G. Consider then a fixed spanning tree T = (V,ET ) of G. Here is a spanning tree (Fig. 3) for our
example of Fig. 1. Its edge set is ET = {e2, e5, e6, e8}. These are the tree branches. The remaining edges
are called chords.
It is easy to see that every spanning tree has n 1 branches. We are going to show that every voltage
configuration v can be written as a linear combination of rows of B. This is nothing else but the familiar
idea that every voltage configuration on the edges of G can be defined by means of a potential configuration
4
e8
e2
e6
e4
e3
e5
e7
e1
_
_
_
_
_
_
_
_
_
_
_____
_____
_____
_____
_____
_____
_____
_____
_____
_____
______
3
54
12
Figure 3: A SPANNING TREE
on the vertices of G. The spanning tree T helps to rigorously prove that. Pick a vertex of T and call it the
root or the ground node. Now, for any vertex k, there is a unique path on T connecting k to the root. Define
the orientation of this path to be that from the root to k. Define the potential pk of vertex k to be the sum
of the voltages over all edges of this path, with the correct sign. That is, if edge e of the path has the same
orientation as the path, then add ve with sign +1, or else, with sign 1. It is now easy to check that for any
edge e = (k, `) (not necessarily in T) the voltage ve is just
ve = pk p`, (9)
i.e., the difference of the potential of the start node minus that of the end node. Indeed, if e is in T, then this is
obvious. If e = (k, `) is a chord, then let s be the vertex at which the path of k and the path of ` first intersect,
and apply KVL at the obvious cycle containing vertices s, k, `. (See Fig. 4.)
_
_
_
__
__
_
_
_
__
_
_
__
__
_
_
__
_
_
__
__
_
_
__
____
__
_
_
_
_
_
_
__
_
__
__
__
__
root
We claim that this last inclusion (10) implies the opposite inclusion of (6). Let i be some current configuration
and v some voltage configuration. Hence v = BTp and Bi = 0. This gives
iTv = iT(BTp) = (Bi)Tp = 0 p = 0.
By the way, this relationship between a current configuration i and a voltage configuration v is called
Tellegens theorem and it is a generalization of the principle of energy conservation.
We now do the following trick: pick set of linearly independent columns of A. Call these columns
a1, a2, . . . , ar. (We can achieve this by starting with the first column of A, then picking the next column that
is not a multiple of a1 and call it a2, then the next one that is not a linear combination of a1, a2, and so on.)
Suppose that aj occurs at the p-th position of A. Let uj be a unit column, with 1 at the p-th position and 0
everywhere else. Then
aj = Auj , j = 1, . . . , r.
Next pick a maximal set of linearly independent voltage configurations. This is easy to do: every row of B
is a voltage configuration. Any n 1 rows (for example all but the last row) are linearly independent. Call
these rows vT1
, . . . , vT
n1. We claim that u1, . . . , ur, v1, . . . , vn1 are linearly independent. Indeed, suppose
that there are numbers _1, . . . , _r, 1, . . . , n1, such that
Xr
j=1
_juj +
nX1
k=1
kvk = 0.
Then, by applying A to both sides (and remembering that Auj = aj , and Avk = 0), we find
Xr
j=1
_jaj = 0.
PBut the aj s have been chosen to be linearly independent; thus _j = 0 for all j = 1, . . . , r. But then n1
k=1 kvk = 0, and, since the vk are linearly independent, we have k = 0, for all k = 1, . . . , n 1.
Now fix a column vector x = (xe, e 2 E) and consider the product Ax. This is really a linear combination
of the columns of A. Since every column is a linear combination of the columns a1, . . . , ar chosen above,
we have that Ax itself is a linear combination of these columns. We can thus write
Ax =
Xr
j=1
_jaj .
Using the same coefficients _j , define the column
y=
X
j=1
_juj .
We have x = (x y) + y, and A(x y) = Ax Ay = 0. Hence x y 2 N(A)VOLT-SP . Thus, any
m-vector x can be written as a sum of a vector in VOLT-SP and a vector y which is the linear combination of
r unit vectors. Remembering that dimVOLT-SP = n 1, we have
m = (n 1) + r.
6
Instead of using the u1, . . . , ur, we can, instead, use r linearly independent rows of A. Call these rows
wT 1
, . . . ,wT
r. The vectors v1, . . . , vn1, w1, . . . ,wr are linearly independent and any m-vector x can be
written as a linear combination of these (n 1) + r = m vectors. In particular, this is true for a current
configuration i: we can write i = v + w, where v is a linear combination of v1, . . . , vn1, and w is a linear
combination of w1, . . . ,wr. Since v 2 VOLT-SP , we know that iTv = 0. Hence 0 = (v+w)Tv = vTv+wTv.
But w = ATu, for some u, because w 2 CYCL-SP . So wTv = (ATw)Tv = wTAv = 0. So vTv = 0, and
this means that v = 0, so that i = w, and so i 2 CYCL-SP . We thus proved any i from CURR-SP is also
contained in CYCL-SP .
CURR-SP _ CYCL-SP . (11)
Putting (6) and (11) together we arrive at the result that CURR-SP is the same as CYCL-SP . In particular, we
have shown that
dimCURR-SP = m n + 1.
MNEMONIC RULE: The V-spaces (VOLT-SP and VERT-SP ) are identical, and so are the C-spaces (CURR-SP and
CYCL-SP ).
If a spanning tree T is chosen then the n 1 potentials pk on every vertex k other than the root define all
voltages. This was explained above. This actually leads to the node method for circuit analysis. In this
method, we consider the n 1 potentials as the unknowns and, for each vertex k which is not root, we write
KCL.
The dual to this method is the loop method. In class, we explained how to pick meshes in a planar graph.
If the graph is not necessarily planar, then the way we pick linearly independent cycles (loops) is again
by considering a spanning tree T. Each edge e which is not in T (called chord) defines a cycle, in the
following manner: if we add e to T then a unique cycle is formed, called the fundamental cycle of the chord
e. For example, in Fig. 3, if we add e1 to the tree we obtain the cycle (4, 3, 2, 5). We give the fundamental
cycle the orientation of the chord that defines it. We showed earlier (11) that CURR-SP _ CYCL-SP . This
means that every current configuration i is a linear combination of cycles. But we never said which is this
linear combination. This is achieved by letting the currents je on each chord (on each fundamental cycle) e
undefined, and by expressing the vector i as a linear combination of these jes. These variables are called
fundamental loop currents. For instance, Fig. 3 can be redrawn as follows (Fig. 5). This figure shows the
fundamental cycles and their currents.
e8
e2
e6
e4
e3
e5
e1 e7
_
_
_
_
_
_
_
_
_
_
_
______
______
______
______
______
______
______
______
______
______
______
_____
_____
54
12
Figure 5: FUNDAMENTAL CYCLES AND CURRENTS
7
Now, a current on a branch of the tree can be expressed as combination of the loop currents for each
fundamental loop containing this branch. So we have
i1 = j1 i5 = j1 + j3 j7
i2 = j4 j3 i6 = j1 j3 + j4 + j7
i3 = j3 i7 = j7
i4 = j4 i8 = j1
Another way to think of these is as follows. Each branch of the tree separates it into two upon its removal.
Let V1, V2 be the set of vertices of each part. For instance, by removing e6 we have V1 = {1, 4, 5} and
V2 = {2, 3}. The removed edge together with the chords from V1 to V2 form a fundamental cut, and each of
the above equations is nothing else but KCL for this fundamental cut. For example, the fundamental cut of
e6 contains e1, e7, e4, e3 and e6. The equation i6 = j1 j3 + j4 + j7 is KCL for this cut. Next observe that
we can write the equations above in matrix form as follows:
0
BBBBBBBB@
i1
i2
i4
i5
i6
i7
i8
1
CCCCCCCCA
= j1
0
BBBBBBBBBB@
1
0
0
0
1
1
0
1
1
CCCCCCCCCCA
+ j3
0
BBBBBBBBBB@
0
1
1
0
1
1
0
0
1
CCCCCCCCCCA
+ j4
0
BBBBBBBBBB@
0
1
0
1
0
1
0
0
1
CCCCCCCCCCA
+ j7
0
BBBBBBBBBB@
0
0
0
0
1
1
1
0
1
CCCCCCCCCCA
In matrix notation,
iT = jT e A,
where e A is the reduced cycle matrix
eA=
0
BB@
1 0 0 0 1 1 0 1
0 1 1 0 1 1 0 0
01010100
0 0 0 0 1 1 1 0
1
CCA
In general, the reduced cycle matrix e A is obtained from the cycle matrix A by eliminating all rows except a
maximal set of linearly independent ones. It thus has m n + 1 rows and m columns.
One then considers the m n + 1 loop currents as unknowns and requires that, for each fundamental
loop, a KVL be written. It leads to m n + 1 linearly independent equations in m n + 1 unknowns.
In practice, choosing the right method, or picking a spanning tree T in a correct way are both matters
that require some experience.
9 Tellegens theorem
This was proven earlier: any current configuration i is orthogonal to any voltage configuration:
iTv = 0.
Notice that the only requirement is that both i and v refer to the same graph. We have not used the identity
of the circuit elements. And, although this can be interpreted as the energy conservation principle, it is a fact
that reflects simply the geometry of the spaces of variables.
8
10 General solution
We present the solution to any linear circuit. First, we assume that the circuit is well-defined. We leave this
notion vague, but what we mean is that the circuit should not contain, for example, current sources connected
in a way that they violate KCL, neither voltage sources violating KVL. By source transformations we can
then reduce the circuit so that each branch e contains a resistor re in series with a voltage source ge. (See Fig.
6.) We then have
g
ie re e
ve
_
_
_
_
_-+
-+
Figure 6: A TYPICAL BRANCH
ve = reie + ge,
for each edge e. In matrix notation,
v = Ri + g, (12)
where R is a diagonal matrix containing the resistances. Now let e B be the reduced incidence matrix, that is,
the matrix B with the last row omitted. This has now the property that all its rows are linearly independent.
Then choose a spanning tree T, as explained earlier. Finally, arrange the edges in two sets, those in T, and
those not in T, and permute the columns of both e B and e A to reflect that splitting. For instance, in the earlier
exaple, e A is rewritten as
eA=
0
BB@
0 1 1 1 1 0 0 0
1 1 1 0 0 1 0 0
10100010
0 1 1 0 0 0 0 1
1
CCA
= ( e AT e AN)
Notice that e AN is the identity matrix. Similarly, write e B = ( e BT e BN), i = (iT , iN), v = (vT , vN). We
write (5) as:
0 = e BT e AT
T + e BN e AT
N = e BT e AT
T + e BN.
Since e BT has n 1 rows and n 1 columns, and its rows are linearly independent, it is invertible. Hence
e AT
T = e B1
T
e BN.
Next, KCL (3) is written as
0 = e Bi = ( e BT e BN)
_
iT
iN
_
= e BT iT + e BNiN.
Hence
iT = e B1
T
e BNiN = e AT
T iN.
This means that
i=
e AT
T e AT
N
!
iN = e ATiN.
Now write KVL (4) together with the branch equations (12).
0 = e Av = e A(Ri + g) = e AR e ATiN + Ag.
9
Observe that e AR e AT is a square matrix of sizemn+1 with linearly independent rows. Hence it is invertible.
So
iN = ( e AR e AT)1 e Ag.
And so, the complete solution of the circuit is
i = e AT( e AR e AT)1 e Ag.
Actually, in this section, not only we have produced a solution, but we have also shown that a solution always
exists and is unique.
__ __
_
_
_ __ __
s
t
_
_
_
_
_
_
_
_
_
_
s
t
b
a
c
d
_
The current on the edge (a, b) is thus equal to (2 1)/11 = 1/11. Similarly, we find
is,d = 1, id,c = 4/11, ic,b = 4/11, id,a = 7/11, ia,b = 1/11, ib,t = 5/11, ia,t = 6/11.
We can extend the formula to the case where the resistances are not necessarily equal. In this case, define
the weight of a spanning tree to be the product of the inverses of the resistances of its edges. Then define
N(s, a, b, t) to be the sum of the weights of all trees at which (a, b) appears. With this new definition, the
previous formula remains valid. See exercises.
11
da
b
b
d
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
_
_
_
_
__
__
__
__
__
__
__
__
__
__
_
__
_
__
__
_
__
__
__
__
__
_
_
__
_
_
__
__
_
_
_
__
__
__
__
__
__
__
__
__
__
_
_
__
__
__ __
__
_
_
_
_
_ _
__
__
__
_
__ _
_
_
__
_
_
_
_
_
_
_
_
__
__
__
_ _
_
_
_
_
__
__
__
__
_ _
_
_
_
_
__
__
__
__
_ _
_ _
__
__
__
__
__
_
_
__ _
_
__
__
__
_
_
__
__
_
_
_
__
__
__ _
__
__
_
_
_
_
__
__
_ _
_ _
__
__
__
(s,d) (d,s) (d,c) (c,d) (c,b) (b,c) (d,a) (a,d) (a,b) (b,a) (b,t) (t,b) (a,t) (t,a)
11 0 4 0 4 0 7 0 2 1 5 0 6 0
d
d
s
t
b
a
c
s
t
b
a
c
s
t
c
s
t
b
a
c
d
s
t
b
a
c
d
s
t
b
a
c
d
s
t
a
c
d
s
t
b
a
c
d
s
t
b
a
c
s
t
b
a
c
d
s
t
b
a
c
d
Exercises
To solve these exercises, you need to have understood the material here, but also have the physical intuition
obtained in the circuit theory class.
1. Show that every connected graph has a spanning tree (easy).
2. If a circuit graph is planar then it can be embedded (=drawn) in the plane. A face is a cycle which
contains no edges inside. Show that the rows of the cycle matrix A corresponding to cycles which are
not faces are linear combinations of the rows which correspond to faces.
3. We claimed that considering graphs where there is at most one edge per pair of vertices is no loss of
generality. Explain how more general circuits (with two or more edges corresponding to at least one
pair of vertices) can be reduced to the previous case. Hint: introduce new vertices.
4. Prove that the rank of the incidence matrix is never equal to the number of edges.
12
References
[1] Bela Bollabas. Graph Theory. Springer-Verlag, New York, 1979.
[2] Charles Desoer and Ernest Kuh. Basic Circuit Theory. McGraw-Hill, 1969.
14__