Graph Theory
Graph Theory
Graph G = (V , E).
V ={vertices}, E={edges}.
a b
h
d
k
e
f
V={a,b,c,d,e,f,g,h,k}
E={(a,b),(a,g),( a,h),(a,k),(b,c),(b,k),...,(h,k)} |E|=16.
Digraph D = (V , A).
V ={vertices}, E={edges}.
a b
h
d
k
e
f
V={a,b,c,d,e,f,g,h,k}
E={(a,b),(a,g),( h,a),(k,a),(b,c),(k,b),...,(h,k)} |E|=16.
Eulerian Graphs
Can you draw the diagram below without taking your pen off the
paper or going over the same line twice?
Bipartite Graphs
A a
B b
C c
D d
Vertex Colouring
R
Colours {R,B,G}
B B
R G
R
a f
d e
b g
c h
If V ′ ⊆ V then
G[V ′ ] = (V ′ , {(u, v ) ∈ E : u, v ∈ V ′ })
b d e G[{a,b,c,d,e}]
c
Similarly, if E1 ⊆ E then G[E1 ] = (V1 , E1 ) where
V1 = {v ∈ V1 : ∃e ∈ E1 such that v ∈ e}
E 1 = {(a,b), (a,d)}
d G[E 1 ]
b
Isomorphism
(v , w) ∈ E1 ↔ (f (v ), f (w)) ∈ E2 .
a A
b d B D
c C
f(a)=A etc.
Complete Graphs
Kn = ([n], {(i, j) : 1 ≤ i < j ≤ n})
is the complete graph on n vertices.
Km,n = ([m] ∪ [n], {(i, j) : i ∈ [m], j ∈ [n]})
is the complete bipartite graph on m + n vertices.
(The notation is a little imprecise but hopefully clear.)
K5
Vertex Degrees
dG (v ) = degree of vertex v in G
= number of edges incident with v
δ(G) = min dG (v )
v
∆(G) = max dG (v )
v
e1 e2 e3 e4 e5 e6 e7 e8
a 1 1 1
b 1 1 1
c 1 1 1
d 1 1 1
e 1 1 1 1
e 1
b c
e5
e e6
e2 e 4
e 8
e7
a e d
3
Adjacency matrix A: V × V matrix.
1 v , w adjacent
A(v , w) =
0 otherwise
a b c d e
a 1 1 1
b 1 1 1
c 1 1 1
d 1 1 1
e 1 1 1 1
e 1
b c
e5
e e6
e2 e 4
e 8
e7
a e d
3
Theorem
X
dG (v ) = 2|E|
v ∈V
Corollary
is even.
So |ODD| is even.
Paths and Walks
a c e
g f
W1 = a,b,c,e,d
W2 =a,b,a,c,e
W3 =g,f,c,e,f
A walk is closed if v1 = vk . A cycle is a closed walk in which the
vertices are distinct except for v1 , vk .
b, c, e, d, b is a cycle.
b, c, a, b, d, e, c, b is not a cycle.
b d
a c e
g f
Theorem
Let A be the adjacency matrix of the graph G = (V , E) and let
Mk = Ak for k ≥ 1. Then for v , w ∈ V , Mk (v , w) is the number
of distinct walks of length k from v to w.
Pk +1 (v , w; x) ∩ Pk +1 (v , w; x ′ ) = ∅ for x 6= x ′
and [
Pk +1 (v , w) = Pk +1 (v , w; x)
x∈V
So,
X
|Pk +1 (v , w)| = |Pk +1 (v , w; x)|
x∈V
X
= |Pk (v , x)|A(x, w)
x∈V
X
= Mk (v , x)A(x, w) induction
x∈V
= Mk +1 (v , w) matrix multiplication
Connected components
We define a relation ∼ on V .
a ∼ b iff there is a walk from a to b.
b d e
a c f
g
a ∼ b but a 6∼ d.
Claim: ∼ is an equivalence relation.
reflexivity v ∼ v as v is a (trivial) walk from v to v .
Symmetry u ∼ v implies v ∼ u.
(u = u1 , u2 . . . , uk = v ) is a walk from u to v
implies (uk , uk −1 , . . . , u1 ) is a walk from v to u.
Transitivity u ∼ v and v ∼ w implies u ∼ w.
W1 = (u = u1 , u2 . . . , uk = v ) is a walk from u to v
and W2 = (v1 = v , v2 , v3 , . . . , vℓ = w) is a walk
from v to w imples that
(W1 , W2 ) = (u1 , u2 . . . , uk , v2 , v3 , . . . , vℓ ) is a walk
from u to w.
The equivalence classes of ∼ are called connected
components.
In general V = C1 ∪ V2 ∪ · · · ∪ Cr where C1 , C2 , . . . ,
Cr are the connected comonents.
We let comp(G)(= r ) be the number of components of G.
G is connected iff comp(G) = 1 i.e. there is a walk between
every pair of vertices.
Thus C1 , C2 , . . . , Cr induce connected subgraphs
G[C1 ], . . . , G[Cr ] of G
For a walk W we let ℓ(W ) = no. of edges in W .
l(W)=6
Lemma
Suppose W is a walk from vertex a to vertex b and that W
minimises ℓ over all walks from a to b. Then W is a path.
For t = 0, 1, 2, . . . , let
At = {w ∈ V : d(v , w) = t}.
A2 A3 A4
A1
v A4 A4
A2 A3
A1
A2 A3
A0 = {v } and v ∼ w ↔ d(v , w) < ∞.
In BFS we construct A0 , A1 , A2 , . . . , by
At+1 = {w ∈
/ A0 ∪ A1 ∪ · · · ∪ At : ∃ an edge
(u, w) such that u ∈ At }.
Theorem
G is bipartite ↔ G has no cycles of odd length.
Proof →: G = (X ∪ Y , E).
Y X
X Y Typical Cycle
Y X
X = A0 ∪ A2 ∪ A4 ∪ · · · and Y = A1 ∪ A3 ∪ A5 ∪ · · ·
k = ℓ:
a
v
vj b
There exist paths (v = v0 , v1 , v2 , . . . , vk = a) and
(v = w0 , w1 , w2 , . . . , wk = b).
Let j = max{t : vt = wt }.
(vj , vj+1 , . . . , vk , wk , wk −1 , . . . , wj )
(a)
v
u
(b)
u v
Proof Every path P in G + e which is not in G must contain
e. Also,
comp(G + e) ≤ comp(G).
Suppose
(x = u0 , u1 , . . . , uk = u, uk +1 = v , . . . , uℓ = y )
u
v
v
u
u1
uℓ−1
u v
Drop in number of components follows from previous Lemma.
The rest follows from
(c) Suppose E = {e1 , e2 , . . . , er } and
Gi = (V , {e1 , e2 , . . . , ei }) for 0 ≤ i ≤ r .
Claim: Gi has n − i components.
Induction on i.
i = 0: G0 has no edges.
i > 0: Gi−1 is acyclic and so is Gi . It follows from part (a) that ei
joins vertices in distinct components of Gi−1 . It follows from (b)
that Gi has one less component than Gi−1 .
End of proof of claim
Thus r = n − k (we assumed G had k components).
Corollary
If a tree T has n vertices then
(a) It has n − 1 edges.
(b) It has at least 2 vertices of degree 1, (n ≥ 2).
So s ≥ 2.
Theorem
Suppose |V | = n and |E| = n − 1. The following three
statements become equivalent.
(a) G is connected.
(b) G is acyclic.
(c) G is a tree.
v
Proof Suppose T has n vertices and n − 1 edges. Then
T − v has n − 1 vertices and n − 2 edges. It acyclic and so
must be a tree.
How many trees? – Cayley’s Formula
n=4
4 12
n=5
5 60 60
n=6
6 120 360 90
360
360
Prüfer’s Correspondence
11
8 4
7
14 6 2
10
9 13 1 12 15
6,4,5,14,2,6,11,14,8,5,11,4,2
Lemma
v ∈ V (T ) appears exactly dT (v ) − 1 times in φV (T ).
s1
ℓ1
T1
φ−1 −1
V (s1 s2 . . . sn−2 ) = φV1 (s2 . . . sn−2 ) plus edge s1 ℓ1 ,
where ℓ1 = min{s ∈ V : s ∈
/ {s1 , s2 , . . . sn−2 }} and
V1 = V − {ℓ1 }. Then
φV (φ−1 −1
V (s1 s2 . . . sn−2 )) = s1 φV1 (φV1 (s2 . . . sn−2 ))
= s1 s2 . . . sn−2 .
8
Number of trees with a given degree sequence
Corollary
If d1 + d2 + · · · + dn = 2n − 2 then the number of spanning trees
of Kn with degree sequence d1 , d2 , . . . , dn is
n−2 (n − 2)!
= .
d1 − 1, d2 − 1, . . . , dn − 1 (d1 − 1)!(d2 − 1)! · · · (dn − 1)!
b h
c
g
f
d
a j
k
The walk using edges a, b, c, d, e, f , g, h, j, k in this order is an
Eulerian cycle.
Theorem
A connected graph is Eulerian i.e. has an Eulerian cycle, iff it
has no vertex of odd degree.
v i+1
v
vj-1
v j+1
The converse is proved by induction on |E|. The result is true
for |E| = 3. The only possible graph is a triangle.
Assume |E| ≥ 4. G is not a tree, since it has no vertex of
degree 1. Therefore it contains a cycle C. Delete the edges of
C. The remaining graph has components K1 , K2 , . . . , Kr .
Each Ki is connected and is of even degree – deleting C
removes 0 or 2 edges incident with a given v ∈ V . Also, each
Ki has strictly less than |E| edges. So, by induction, each Ki
has an Eulerian cycle, Ci say.
We create an Eulerian cycle of G as follows: let
C = (v1 , v2 , . . . , vs , v1 ). Let vit be the first vertex of C which is in
Kt . Assume w.l.o.g. that i1 < i2 < · · · < ir .
W =
(v1 , v2 , . . . , vi1 , C1 , , vi1 , . . . , vi2 , C2 , vi2 , . . . , vir , Cr , vir , . . . , v1 )
is an Eulerian cycle of G.
K1
i1
K 2
i2
C
i3
K3
Independent sets and cliques
n2
α(G) ≥ .
2m + n
n
Note that this says that α(G) is at least d+1 where d is the
average degree of G.
Proof Let π(1), π(2), . . . , π(ν) be an arbitrary permutation
of V . Let N(v ) denote the set of neighbours of vertex v and let
Proof of Claim 1
Suppose w1 , w2 ∈ I(π) and w1 w2 ∈ E. Suppose π(w1 ) < π(w2 ).
Then w2 ∈/ I(π) — contradiction.
f
b d
h
c e g
a b c d e f g h I
π1 c b f h a g e d {c, f }
π2 g f h d e a b c {g, a}
Claim
If π is a random permutation then
X 1
E(|I|) = .
d(v ) + 1
v ∈V
1 v ∈I
Proof: Let δ(v ) =
0 v∈/I
Thus
X
|I| = δ(v )
v ∈V
X
E(|I|) = E(δ(v ))
v ∈V
X
= Pr(δ(v ) = 1).
v ∈V
Now δ(v ) = 1 iff v comes before all of its neighbours in the
order π. Thus
1
Pr(δ(v ) = 1) =
d(v ) + 1
and the claim follows.
Thus there exists a π such that
X 1
|I(π)| ≥
d(v ) + 1
v ∈V
and so
X 1
α(G) ≥ .
d(v ) + 1
v ∈V
We finish the proof of the theorem by showing that
X 1 n2
≥ .
d(v ) + 1 2m + n
v ∈V
1 1 1 k2
+ + ··· + ≥ . (2)
x1 x2 xk x1 + x2 + · · · + xk
Proof
Multiplying (2) by x1 + x2 + · · · + xk and subtracting k from both
sides we see that (2) is equivalent to
X xi xj
+ ≥ k (k − 1). (3)
xj xi
1≤i<j≤k
(k − 2)n2
m≤
2(k − 1)
By assumption
n2
k − 1 ≥ α(Ḡ) ≥ .
n(n − 1) − 2m + n
Parallel searching for the maximum – Valiant
4 10
3
6
5
2
1
Suppose that the first round of comparisons involves comparing
xi , xj for edge ij of the above graph and that the arrows point to
the larger of the two values. Consider the independent set
{1, 2, 5, 8, 9}. These are the indices of the 5 largest elements,
but their relative order can be arbitrary since there is no implied
relation between their values.
Let C(a, b) be the maximum number of rounds needed for a
processors to compute the maximum of b values in this way.
Lemma
b2
C(a, b) ≥ 1 + C a, .
2a + b
ck ≥ 2 implies C(n, n) ≥ k + 1.
Claim 4 now follows from
Claim
n
ci ≥ .
32i −1
n2 1
ci+1 ≥ × n
32i+1 −2 2n + i
32 −1
n 3
= 2i+1 −1
× 1
3 2+ i
32 −1
n
≥ 2i+1 −1
.
3
We found an upper bound on the number of edges m ≤ n2 /4
on graphs without triangles. We find a smaller bound if we
exclude cycles of length four.
Theorem
If G contains no cycles of length four then m ≤ (n3/2 + n)/2.
Thus
X d(y )
N =
2
y ∈V
1X
= −m + d(y )2
2
y ∈V
n 2m 2
≥ −m +
2 n
Thus
n2 − n 2m2
≥ −m + .
2 n
We re-arrange to give
n n3 − n2
m2 − m− ≤0
2 4
or
n 2 n 3 n2
m− − − ≤0
4 4 16
which implies that
n n3/2 n
m− ≤ + .
4 2 4
Matchings
A matching M of a graph G = (V , E) is a set of edges, no two
of which are incident to a common vertex.
M-saturated
M={ }
M-unsaturated
M-alternating path
M not M M not M M
b d
(a,b,c,d,e,f) is an
M-alternating path
f
b1 b3
a0 b2
M ′ = M − {f1 , f2 , . . . , fk } + {e1 , e2 , . . . , ek +1 }.
|M ′ | = |M| + 1.
M ′ is a matching
For x ∈ V let dM (x) denote the degree of x in matching M, So
dM (x) x 6∈ {a0 , b1 , . . . , bk +1 }
dM (x) is 0 or 1. dM ′ (x) = dM (x) x ∈ {b1 , . . . , ak }
dM (x) + 1 x ∈ {a0 , bk +1 }
So if M has an augmenting path it is not maximum.
Suppose M is not a maximum matching and |M ′ | > |M|.
Consider H = G[M∇M ′ ] where M∇M ′ = (M \ M ′ ) ∪ (M ′ \ M) is
the set of edges in exactly one of M, M ′ .
Maximum degree of H is 2 – ≤ 1 edge from M or M ′ . So H is a
collection of vertex disjoint alternating paths and cycles.
(a) (b)
x
Bipartite Graphs
a2 b2
a3 b3
a4 b4
N({a 2 , a 3 }) ={ b 1 b 3 b4 }
Theorem
G contains a matching of size |A| iff
a1 b1
a2 b2
a3 b3
a4 b4
1 φ (2) ε N(S)
2 φ (4)
+non-matching
S
edges
3 φ (1) ε N(S)
4 φ (3) ε N(S)
B1 B1 B1 B1
a0 A1 A1 A1 A1
No A 1 - B\B 1
edges
• B1 is M-saturated else there exists an M-augmenting path.
• If a ∈ A1 \ {a0 } then φ(a) ∈ B1 .
a0 φ(a) a
• If b ∈ B1 then φ−1 (b) ∈ A1 \ {a0 }.
So |B1 | = |A1 | − 1. • N(A1 ) ⊆ B1
a0 b a
So |N(A1 )| = |A1 | − 1 and (4) fails to hold.
Marriage Theorem
Theorem
Suppose G = (A ∪ B, E) is k -regular. (k ≥ 1) i.e. dG (v ) = k for
all v ∈ A ∪ B. Then G has a perfect matching.
{ } is a covering
Lemma
If X is a covering and M is a matching then |X | ≥ |M|.
S0 S0 S0 S S S S
Let X = (A \ S) ∪ T .
• |X | = |M|.
|T | = |S \ S0 |. The remaining edges of M cover A \ S exactly
once.
• X is a cover.
There are no edges (x, y ) where x ∈ S and y ∈ B \ T .
Otherwise, since y is M-saturated (no M-augmenting paths) the
M-neightbour of y would have to be in S, contradicting y ∈
/ T.