0% found this document useful (0 votes)
49 views

MATH1081 Topic 5 Slides

The document discusses graph theory concepts. It defines a graph as consisting of vertices and edges, which connect pairs of vertices. It then defines concepts such as paths, cycles, walks, degrees of vertices, and adjacency matrices. It discusses properties of various graphs including trees, cycles, complete graphs, bipartite graphs, and graph complements. It also introduces multigraphs, which allow multiple edges between vertex pairs and loops within a single vertex.

Uploaded by

hieu2048
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

MATH1081 Topic 5 Slides

The document discusses graph theory concepts. It defines a graph as consisting of vertices and edges, which connect pairs of vertices. It then defines concepts such as paths, cycles, walks, degrees of vertices, and adjacency matrices. It discusses properties of various graphs including trees, cycles, complete graphs, bipartite graphs, and graph complements. It also introduces multigraphs, which allow multiple edges between vertex pairs and loops within a single vertex.

Uploaded by

hieu2048
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Topic 5.

Graph Theory

A graph G consists of vertices V (dots) and edges E (lines


between dots).

Each edge is an unordered pair of distinct vertices:


that is, a set containing exactly two vertices.

We write vw to represent the edge {v, w} between vertices


v and w.

d e g

a
b c f

Graphs are also called networks; vertices are also called


nodes; edges are sometimes called arcs.

Formally, a (finite) graph G consists of

• A finite set V = V (G) of vertices,

• A set E = E(G) of edges, where each edge is an unordered


pair of distinct vertices.

When we draw a graph, vertices have no fixed position, and


edges do not need to be straight.
Example. Draw the graph G with vertex set

V = {a, b, c, d, e, f }
and edge set

E = {ab, bc, bd, cd, de, ef }.

Sometimes we want something a bit more flexible than a


graph. We want a multigraph!

A multigraph G consists of

• a set V = V (G) of vertices,

• a set E = E(G) of edges,

• and a function f : E → P (V ), called the endpoint function,


such that f (e) is a set of either one or two vertices from V ,
for each edge e ∈ E.

The vertices in f (e) are called the endpoints of e.


Multigraph terminology:

• If exactly r edges have the same set of endpoints {v, w}


then we say that {v, w} is an edge of multiplicity r.

• An edge with multiplicity greater than 1 is called a


repeated edge.

• Edges with the same endpoints are called parallel edges


or multiple edges.

• A loop is an edge with only one endpoint.

Note: Every graph can also be regarded as a multigraph.

Example.
Consider the multigraph G with vertices and edges:

V = {v1, v2, v3, v4, v5} and E = {e1, e2, e3, e4, e5, e6, e7} :

Edge Endpoints
v3 e1
e2 e4 e2
e5 e3
e6 e4
e1 v2 e3 v4 e7 e5
v1 v5
e6
e7
If e = vw is an edge of a graph or multigraph G, then we
say that

• v and w are adjacent;

• v and w are neighbours;

• edge e is incident with v and w;

• vertices v and w are the endpoints of e.

A multigraph is simple if it has no loops and no edge with


multiplicity greater than 1. So a graph is just a simple
multigraph.

The degree of a vertex v, denoted by deg(v), is the number


of edges incident with v, counting any loops twice.

An isolated vertex is a vertex with degree 0.

A pendant vertex is a vertex with degree 1.


Example: vertex degrees.

v deg(v)
a
a b
d e c
b
d
c e
f
f g g

Exercise.
How many loops, isolated vertices and pendant vertices are
there in this multigraph?

Example.

Path P4 Cube Q3

Cycle C5 Complete graph K5


Exercise.

How many vertices and edges do Pn, Cn, and Kn each have?

Path Pn Cycle Cn Complete graph Kn

|V |:

|E|:

Example.

Cycle C5 Complete graph K5 Cube Q3

The vertices in Cn each have degree .

The vertices in Kn each have degree .

The vertices in Q3 each have degree .

A graph is regular if every vertex has the same degree.

Every cycle Cn is regular of degree .


The Handshaking Lemma.
For any graph or multigraph G,
X
2|E| = deg(v).
v∈V

Proof.

Example.

a
d e
b
c

f g

Exercise.
The vertices of Qn can be labelled as bit strings:
n o
V (Qn) = {0, 1}n = a1 · · · an : ai ∈ {0, 1}

010 110
111
How many vertices does Qn have? 011

How many edges does Qn have? 001


101

000 100
Cube Q3
Challenge: Draw Q4.

?
Q1 Q2 Q3 Q4

Now we return to graphs, with no loops and no repeated


edges.

Exercise:
Prove that no graph can have the following vertex degrees:

• 5,4,3,2,1

• 4,3,3,1,1

(Are there any multigraphs with these degrees?)


Definition. A graph G on the vertex set V is bipartite if
V = X ∪ Y for some disjoint sets X, Y so that each edge of
G has an endpoint in X and an endpoint in Y .

Example. Is the following graph bipartite?

b c

a d

f e

Exercise. Is the cycle C5 bipartite?

b e

c d
Example. The complete bipartite graph Km,n

K1,2 K2,2 K3,2

Km,n has vertices and edges.

Definition. A graph G is a subgraph of another graph H,


written G ⊆ H, if

• V (G) ⊆ V (H) and

• E(G) ⊆ E(H).

(We will not define “sub-multigraphs”.)

Example. G ⊆ H
b b
G a e a d e H
c c
Definition. Let G be a graph with vertex set V and edge
set E. The complement G of G is the graph with vertex set
V , such that

vertices a and b are neighbours in G if and only if


they are not neighbours in G.

Let V {2} denote the set of all subsets of V of cardinality 2.


Then we can also define the complement G as follows:
V (G) = V (G) and E(G) = E(G)c = V {2} − E(G).

Example.

G G

Exercise:

If a graph G has n vertices and m edges then its complement


G has edges.
Definition.
Let G be a multigraph with ordered vertices v1, . . . , vn.
An adjacency matrix for G is an n × n matrix A = [aij ] with

aij = number of edges with endpoints vi and vj .

Example.
v2 v3 v3 v2
v1 v1
   

A= A=
   
 

Definition. Let G be a multigraph with vertices u and v.

A walk from u to v in G is a finite alternating sequence of


vertices and edges

v0, e1, v1, e1, v2, · · · , vn−1, en, vn


with v0 = u and vn = v, such that ei is incident with vi−1
and vi for i = 1, . . . , n.

The length of this walk is n.

If G is a graph (i.e., simple) then we do not need to write


down the edges, and the walk can be written as

v0v1v2 . . . vn−1vn.
A walk is closed if it starts and ends in the same vertex:
v0 = v n .

Example.
b y e2 u

e1 e4 e5
a d x w
c e3 z e6

a c d c d is a walk of length 4 from a to d.

a b c d c a is a closed walk of length 5.

Two different walks from x to z of length 3 are


x, e1, y, e2, u, e4, z and x, e1, y, e2, u, e5, z .

Definition.

A path is a walk with no repeated vertices.

A cycle is a walk which does not use the same edge twice,
begins and ends at the same vertex, but which otherwise
has no repeated vertices.

Notes:

• If a path is closed then it has length .

• Every cycle is a closed walk.


Example. c
b e
a f

a b c e f is a path of length 4 from a to f .

c e d b c is a cycle of length 4.

Exercise.

a c

How many paths of length 3 are there from a to c?

How many walks of length 3 are there from a to c?


Theorem. If there is a walk from a to b in a multigraph G
then there exists a path from a to b in G.

Proof.

Theorem. Let A be the adjacency matrix for multigraph G


with ordered vertices v1, . . . , vn.
(k)
The number of walks of length k from vi to vj in G is aij ,
the entry in the ith row and jth column of Ak .

Before we prove this, let’s look at an example.


 
b 0 1 1 0
1 0 1 0
a d A=
 
1 1 0 1

c
0 0 1 0

   
2 1 1 1 2 3 4 1
1 2 1 1 3 2 4 1
A2 =  A3 = 
   
1 1 3 0 4 4 2 3
 

1 1 0 1 1 1 3 0

From A2 we can see that there are

• 3 walks of length 2 from c to c

• 4 walks of length 3 from a to c, namely...

Proof of Theorem.
Definition. A graph G is connected if for any two vertices
a, b there is a walk from a to b.

The connected components of G are its maximal connected


subgraphs.

Example. Consider graphs G (left) and H (right).


d

a b

Exercise. Define the relation ∼ on the vertex set of graph


G by a ∼ b if and only if there is a walk from a to b in G.

Show that ∼ is an equivalence relation on the vertex set


of G, and that the equivalence classes are the connected
components of G.
Euler trails, Euler tours, Hamilton paths, Hamilton cycles

Definition. Let G be a connected multigraph.

• An Euler trail in G is a non-closed walk which uses


each edge exactly once.

• An Euler tour in G is a closed walk which uses each edge


exactly once.

• A Hamilton path in G is a path which passes through


each vertex exactly once.

• A Hamilton cycle in G is a cycle which passes through


each vertex exactly once (only counting the start/end
vertex once).

Example. Consider K3,2 and K5.

a
X Y
e b

a b c
d c

K3,2 K5
Euler trail? X aY bX cY No
Euler tour? No abcdeacebda
Hamilton path? aX bY c abcde
Hamilton cycle? No abcdea
Theorem. Let G be a connected multigraph. Then

• G has an Euler tour if and only if each vertex of G has


even degree,

• G has an Euler trail if and only if exactly 2 vertices have


odd degree.

Proof.
A circuit is a closed walk which uses each edge at most
once.

Euler Tour Algorithm

⋆ Set C := v0 for some vertex v0 of G.

⋆ Choose a circuit C ′ with at least one vertex v,


but no edge, of C.

⋆ Replace one occurrence of v in C by C ′.

⋆ Continue this process until C contains all edges of G.

⋆ Then C is an Euler tour for G.

Example. Find an Euler tour in the following graph.


b
g
e
a c f
h
d
Apply the Euler Tour Algorithm:
The Königsberg Bridge Problem

18th century Königsberg had seven bridges connecting four


parts of town:
C
C

A D A D

B
B

Can you cross each bridge exactly once and return to where
you started? To solve this problem, Leonhard Euler invented
graph theory.

Here, all four vertices have odd degree so there is no Euler


tour (and no Euler trail).

There are no known simple conditions to decide whether


or not a connected graph has a Hamilton path or cycle.
However:

• A graph with a vertex of degree 1 cannot have a


Hamilton cycle.

• Each Hamilton cycle contains all edges incident with


each vertex of degree 2.

• Each Hamilton path/cycle uses at most 2 edges incident


with any vertex.
Example.

G H

By the first observation, G has no Hamilton cycle.

By the other two observations, any Hamilton cycle in H


must contain the outer edges of H.

But these edges form a cycle which does not contain the
inner vertices. So H has no Hamilton cycle.

Dirac’s Theorem (1962)


Let G be a graph with n ≥ 3 vertices. If deg(v) ≥ n
2 for all
v ∈ V (G) then G has a Hamilton cycle.

Note: Some graphs have Hamilton cycles but do not satisfy


the conditions of Dirac’s Theorem.

In other words, Dirac’s Theorem gives a condition which is


sufficient but not necessary.
Example. Does the cycle Cn have a Hamilton cycle?
Does the complete graph Kn have a Hamilton cycle?

Cn Kn

Definition.
Graphs G and H are isomorphic, written G ≃ H, if there is
a bijection f : V (G) → V (H) such that

• v and w are adjacent in G if and only if


f (v) and f (w) are adjacent in H.

Roughly speaking, two graphs are isomorphic if they are


the same except for the vertex labels.
Example. Are the graphs G and H isomorphic?

d c w z u f (u)
a
b
a x y c
b
d
G H

Definition. A property of a graph G is an invariant if H also


has this property whenever H ≃ G.

Some graph invariants:


• number of vertices, number of edges
• number of vertices of a given degree
• bipartiteness, connectedness
• having a vertex of degree d with a neighbour of degree d′
• number of cycles of a given length
• existence of an Euler tour
• existence of a Hamilton cycle

. . . and many more!

If some invariant property holds for G but not for H then


G 6≃ H.
Example. Are these two graphs isomorphic?

G H

Exercise. Are these two graphs isomorphic?

G H
Exercise. Are these two graphs isomorphic?

G H

Planar graphs

Definition. A multigraph is planar if it can be drawn on a


page without crossing edges.

Such a drawing is a planar map or planar representation


of G.

Example.

K4 a planar map of K4
Exercise. Prove that K2,3 is planar.

K2,3

We will see later that K5 and K3,3 are not planar.

Definition. A planar map divides the plane into regions, one


of which is unbounded. Edge e and region R are incident if
e lies on the boundary of R.

Example.

R e
S T

This planar map has three regions, R, S, T .

The unbounded face is R.

Edge e is incident with faces .


Euler’s Formula.
Let G be a connected planar multigraph with e edges and v
vertices, and suppose that there are r regions in some planar
map of G. Then
v − e + r = 2.

By Euler’s Formula, the number of regions is the same for


all planar maps of G. It depends only on the number of
vertices and edges of G.

Example.
Here are two planar maps of the same planar multigraph.

R R
S T S T

These planar maps have


v = 3 vertices, e = 4 edges, and r = 3 regions.

Thus for both maps, v − e + r = 2 as claimed by Euler’s


Formula.
Exercise.
Let G be a connected planar multigraph with 8 vertices,
each with degree 3.
How many regions are there in a planar map of G?

Lemma.
Let G be a connected multigraph with n ≥ 2 vertices.
If G has no cycles then G is a (simple) graph and G has a
pendant vertex (that is, a vertex of degree 1).

Proof.
Proof of Euler’s Formula.

Definition. The degree deg(R) of a region R is the number


of edges incident with it, except that if the same region
appears on both sides of an edge then this edge counts
twice.

We can also say that the degree of a region in a planar


map is the number of edges (counting repetitions) that are
traversed if you walk around the boundary of the region.
Example.

R A B C D
A B D
C deg(R)

The Handshaking Lemma (Regions).


X
2|E| = deg(R).
regions R
Proof.

Example.

A B D
C
Definition. A dual of a planar map G is a planar map G∗
given as follows:

• each region R of G has an associated vertex vR in G∗,


• each edge e of G has an associated edge e∗ in G∗ so that

• e lies between regions R,R′ if and only if


e∗ is incident with vR , vR′ .

Example.

G G∗

Fact: Let G be a (simple) connected planar graph with at


least 3 vertices. Then every region degree in G is at least 3.

• To have a region of degree 1, G must have a loop.

• To have a region of degree 2, G must have parallel edges.


Theorem.
Let G be a connected planar graph with e edges and v ≥ 3
vertices. Then

• e ≤ 3v − 6,

• e ≤ 2v − 4 if G has no cycles of length 3.

This theorem is useful for proving that some graphs are not
planar.

Proof.
Example. Prove that K5 is not planar.

Example. Prove that K3,3 is not planar.

Definition. A graph G is a subdivision of a graph H if G


is obtained from H by repeatedly replacing some edges by
paths of length 2 or more:

a b a b

Example.

Here is K5 and two subdivisions of K5.


If G is planar then so is any subdivision of G.

Kuratowski’s Theorem (1930)


A graph is planar if and only if it does not contain as a
subgraph

• K5, or

• K3,3, or

• any graph which is a subdivision of K5 or K3,3.

(Informally, this says that K5 and K3,3 are basically the only
barriers to planarity.)

Example. Show that G is not planar.

w
a x

y b

c z
G

The earlier theorem on planarity is of no use here since


e = 13 ≤ 18 = 3v − 6 and since G has cycles of length 3.
v v

w w
a x a x a x

y b y b y b

c z c z c z
G G′ H

However, G has a subgraph G′ which is a subdivision of H


and H ≃ K3,3.

By Kuratowski’s Theorem, G is not planar.

Definition. A tree is a connected graph with no cycles.

Example.

Not a tree A tree

Lemma. A tree is a simple graph.

Proof.
Theorem. Every tree on n vertices has n − 1 edges.

Proof.

Exercise. Use Euler’s Formula to prove this theorem.

Definition. A spanning tree in G is a tree in G that contains


all vertices of G.

Example

Theorem. Every spanning tree of a connected graph G has


the same number of edges.

Proof.
Theorem. Every connected graph contains a spanning tree.

Proof.

Theorem.
A connected graph on n vertices is a tree if and only if it
has n − 1 edges.

Proof.
Definition.
A weighted graph is a graph with numbers (weights)
assigned to its edges.

The weight of a graph is the sum of its edge weights.

A minimal spanning tree of a graph is a spanning tree with


minimal weight.

A path from vertex a and vertex b in a graph is shortest if


it has least weight.

Example.
a a a
G: T1 : T2 :
5 4 4 4
1 1 1
2 5
b b b 2
2 2 2
1 4 1

The weight of G is 5 + 1 + 4 + 2 + 5 + 1 + 2 + 4 = 24.

Both T1 and T2 are spanning trees of G. In fact, T1 is a


minimal spanning tree, with weight 1 + 4 + 1 + 2 = 8.

But T2 has weight 1 + 4 + 2 + 2 = 9, so it is not a minimal


spanning tree of G. However, T2 contains a shortest path
from a to b, and T1 does not.
Kruskal’s Algorithm (1956)

Let G be a connected graph with edge set E.

1. Set T = ∅.

2. Let A be the set of edges of G not in T that


form no cycle with T .

3. Choose an edge e from A with smallest weight.

4. Add e to T .

5. Continue until T contains all vertices of G.

6. Then T is a minimal spanning tree for G.

Example.
Find a minimal spanning tree for this weighted graph.

a 5 b 4 c 2 d Edge Weight Chosen?


dj 1
3 ei 1
3 8 3
bi 2
e 2 f g 1 cd 2
2 fg 2
4 1 gj 2
3 2 ae 3
be 3
h 6 i 4 j
cg 3
fi 3
bc 4
eh 4
ij 4
ab 5
hi 6
cf 8
Let G be a connected graph with positive edge weights, and
let a ∈ V (G).

Consider a shortest path from a to v for each vertex v in G.

Definition.
The union of these paths forms a minimal a-path spanning
tree for G.

A minimal a-path spanning tree is not generally a minimal


spanning tree.

Example. The tree T1 below is a minimal spanning tree in


G, while T2 is a minimal a-path spanning tree in G.

a a a
G: T1 : T2 :
5 4 4 4
1 1 1
2 5
b b b 2
2 2 2
1 4 1
Let G be a connected weighted graph with positive edge
weights, and let a ∈ V (G).

Dijkstra’s Algorithm (1959)

1. Set T = {a}.
2. Let A be the set of edges with one vertex v not in T and
the other in T .
3. Choose an edge e from A that gives a shortest path from
a to any v.
4. Add e to T .
5. Continue until T contains all vertices of G.
6. Then T is a minimal a-path spanning tree for G.

Example. Find the shortest paths from vertex a to each of


the other vertices.
b 2 a 7 c
6 1
1 2
e 3 f
d
2 4
2 3
g 4 h 1 i

Edge candidates Next Next


edge vertex
The shortest distances from a to the other vertices are:

b c d e f g h i
2 6 5 1 4 3 4 5

You might also like