Chapter 6: Graph Theory

advertisement
Discrete and Combinatorial
Mathematics
R. P. Grimaldi,
5th edition, 2004
Chapter 7
Graph Theory
1
In the beginning…
Leonhard Euler


Swiss mathematician, 1707-1783.
First paper in graph theory. In 1736, he wrote a solution to the
problem of Königsberg bridges.
Problem of the Königsberg bridges:


In East Prussia
Starting and ending at the same region, is it possible to cross
all seven bridges just once and return to the starting region?
Pregel river
Kneiphof island
2
Graphs

A graph G = (V, E) consists



V = V(G) : set of vertices (vertex set)
E = E(G)  VV : set of edges (edge set)
If E(G) is a set of ordered pairs, then
G is called a directed graph;
otherwise an undirected graph.
w
v
x
u
w
v
Example:


V = {x, u, v, w}
E = {(x,v), (x,u), (u,v), (v,w), (u,w)}
x
u
3
Subgraphs

If G = (V, E) is a graph, then G1 = (V1,E1) is
called a subgraph of G if   V1  V and E1 
E, where each edge in E1 is incident with
vertices in V1.
w
v
x
G
u
v
x
G1
u
4
Edges
An edge is labeled by a pair of vertices, for
instance e = (v,w).





e is said to be incident with v and w.
v and w are said adjacent.
isolated vertex: a vertex without incident edges.
loop: an edge whose endpoints are equal.
parallel edges: edges with the same endpoints.
e
v
w
isolated
vertex
loop
parallel
edges
5
Representations of graphs
Adjacency matrix



Rows and columns are labeled with ordered vertices.
Aij = 1, if there is an edge between the row vertex
and the column vertex.
Aij = 0 if no edge exists between them.
Incidence matrix



Label rows with vertices
Label columns with edges
Iij = 1 if an edge is incident to a vertex, Iij = 0
otherwise.
6
Different graphs

Simple graph
A graph without loops or parallel edges.

1
Weighted graph
A graph where each edge is assigned a
numerical label or “weight”.
2
4
6
8
7
Walks
G = (V,E) : an undirected graph,
x ,y  V (not necessarily distinct)
x-y walk in G: a loop-free finite alternating
sequence x  x0 , e1 , x1 , e2 , x2 , e3 ,, en1 , xn1 , en , xn  y
of vertices and edges, where ei = (xi-1,xi).
 length of the walk = n.
 x-y walk with x = y: closed walk.
 Note: A walk may repeat both vertices and edges.

8
Trails, Circuits, and Paths




If no edge in the x-y walk is repeated, then the
walk is called an x-y trail.
A closed x-y trail is called a circuit.
If no vertex of the x-y walk repeated, then the
walk is called an x-y path.
y
A closed x-y path is called a cycle.
e6
e
trail : x, e1 , v, e3 , u, e5 , w, e2 , v, e6 , y
circuit : x, e1 , v, e6 , y, e7 , w, e2 , v, e3 , u, e4 , x
path : x, e1 , v, e2 , w, e7 , y
cycle : x, e1 , v, e2 , w, e5 , u, e4 , x
e2
v
e1
x
e3
7
w
e5
e4
u
9
Connected graphs


Let G = (V,E) be an undirected graph. We call G
connected if there is a path between any two
distinct vertices of G; otherwise it is called
disconnected.
Each connected subgraph of a disconnected
graph G is called a component of G.
G
H
10
Spanning subgraphs

Given a grapg G = (V, E), let G1 = (V1,E1) be a
subgraph of G. iIf V1 = V then G1 is called a
spanning subgraph of G.
w
v
x
G
u
w
v
x
G1
u
11
Induced subgraphs

Given a grapg G = (V, E). If   U  V, the
subgraph induced by U, denoted by <U>, is the
subgraph whose vertex set is U and which
contains all edges with both endpoints in U.
w
v
x
G
u
v
x
<U>
u
12
Complete graphs

The complete graph Kn is the simple graph
with n vertices and every pair of vertices is
joined by an edge.
Example: K5
13
Complement graphs

Let G be a simple graph with n vertices. The
complement of G, denoted by G , is the
subgraph of Kn consisting of the n vertices in G
and all edges that are not in G.
Example:
G
G
14
Bipartite graphs
A simple undirected graph is called bipartite if
there exists a partition of the vertex set so that
V1V2= and no edges incident with two
vertices in the same subset Vk, k = 1,2.
V2
V1
15
Complete bipartite graphs
A bipartite graph G = (V,E) with vertex partition V1
and V2 , where |V1| = m and |V2| = n, is the
complete bipartite graph, denoted by Km,n, if
every vertex in V1 is joined to a vertex in V2 and
vice versa.
V2
V1
16
Isomorphic graphs
G1 and G2 are isomorphic if there exist one-to-one
onto functions f: V(G1) → V(G2) and g: E(G1) →
E(G2) such that an edge e is adjacent to
vertices v, w in G1 if and only if g(e) is adjacent
to f(v) and f(w) in G2
aq, bv, cu, dy, er, fw, gx, ht, iz, js
17
Degree of a vertex
The degree of a vertex v, denoted by deg(v), is
the number of edges incident on v.
Example:

deg(a) = 4, deg(b) = 3,
deg(c) = 2, deg(d) = 3.
a
c
b
d
18
Sum of vertex degrees
Theorem 11.2 If G = (V,E) is an undirected
deg( v)  2 | E | .
graph, then

vV
Proof. Each edge contributes exactly two
counts, one count (degree) for each
endpoint.

#
deg( v)  2 | E | .

vV
Corollary 11.1 For any undirected graph, the
number of vertices of odd degree must be
even.
19
Regular graphs
An undirected graph where each vertex has the
same degree is called a regular graph. If deg(v)
= k for all vertices v, then the graph is called kregular.
001
Hypercube Qn: n regular.
011
010
000
111
101
100
110
20
Euler circuit
Let G = (V,E) be an undirected graph with
no isolated vertices. Then G is said to
have an Euler circuit if there is a circuit
in G that traverses every edge of the
graph exactly once.
The Königsberg bridge problem:
Starting and ending at the same region, is it
possible to cross all seven bridges just once
and return to the starting region?
This problem can be represented by a
graph. Edges represent bridges and
each vertex represents a region.
21
Euler graphs
Theorems 11.3 Let G = (V,E) be an undirected
graph with no isolated vertices. Then G has an
Euler circuit if and only if G is connected and
all its vertices have even degree.
Therefore, the Konigsberg bridge problem has
no solution.
22
Proof(1)
() Trivial.
() Step 1. Start from an arbitrary
vertex, go through an unused edge
whenever it exists, and terminate at a
vertex whose incident edges are all
used.
1
2
6
3
5
1265461
4
23
Proof(2)
Step 2. Remove used edges and repeat
step 1. for the remaining graph (start
from a visited vertex).
1
2
6
3
5
2342
4
24
Proof(3)
Step 3. Augment the path obtained so
far with the result of step 2.
1234265461
Step 4. Repeat step 2 and step 3 until all
the edges are used.
#
25
Planar graphs
A graph G is planar if it can be drawn in the plane
with its edges intersecting only at vertices of G;
otherwise it is nonplanar.
a
c
b
d
a planar graph
a nonplanar graph
26
Elementary subdivision
Let G = (V,E) be a loop-free undirected graph,
where E. An elementary subdivision of G
results when an edge e = (u,w) is removed from
G and then the edges (u,v), (v,w) are added to
G-e, where vV.
v
u
w
27
Homeomorphic graphs
The loop-free undirected graphs G1 and G2 are
called homeomorphic if they are isomorphic or if
they can both be obtained from the same loopfree undirected graph H by a sequence of
elementary subdivisions.
28
Kuratowski’s Theorem
A graph is nonplanar if and only if it contain a
subgraph that is homeomorphic to either K5 or
K3,3.
a
j
g
f
e
j
d
a
b
h
g
c
i
i
h
c
d
Peterson graph
e
f
b
29
Euler’s Theorem
Theorem 11.6 Let G = (V,E) be a connected planar
graph with |V| =v and |E| = e. Let r be the number
of regions in the plane determined by a planar
embedding. Then v – e + r = 2.
Proof. By induction.
R3
R4
R2
R1
v=4
e=6
r=4
 v – e + r = 2.
30
Variant of Euler’s Theorem
Corollary 11.3 Let G = (V,E) be a loop-free
connected planar graph with |V| =v and |E| = e >
2, and r regions. Then 3r  2e and e  3v - 6.
Proof. For each region R, the degree of R, denoted
by deg(R), is the number of edges traversed in a
closed walk about the boundary of R.
Each region has at least three edges.
 Each region has degree  3.
The sum of the degrees of the r regions is 2e.
 2e  3r.  e  3v – 6. (By Euler’s Theorem) #
31
Hamilton’s toy
William Rowan Hamilton


Irish mathematician, 1805-1865
In 1859, he developed a game sold to a Dublin toy
manufacturer. The object of the game was to find a
cycle containing all vertices.
32
Hamilton paths and cycles
If G = (V,E) is a graph with |V|  3, we say that G has a
Hamilton cycle if there is a cycle in G that contains every
vertex in V.
Theorem 11.8 Let G = (V,E) be a loop-free graph with |v| =
n  2. If deg(x) + deg(y)  n – 1 for all x, y  V, x  y, then
G has a Hamilton path.
A Hamilton path is a path in G that contains each vertex.
Theorem 11.9 Let G = (V,E) be a loop-free graph with |v| =
n  3. If deg(x) + deg(y)  n – 1 for all nonadjacent x, y 33
 V, then G has a Hamilton cycle.
Gray code
A Gray code is a sequence s1, s2,…, s2 n such that
 every n-bit string appears somewhere in the
sequence
 sk and sk+1 differ in exactly one bit
 s2 n and s1 differ in exactly one bit.
000001011010110111101 100
34
A Hamiltonian cycle
on the hypercube
001
011
010
000
111
101
100
110
35
Trees and Forests
Let G = (V,E) be a loop-free undirected graph.
The graph G is called tree if G is connected and
contains no cycles.
G is called forest if G contains no cycles and is
not connected.
tree
forest
36
Properties of Trees
Theorem 12.1 If a, b are distinct vertices in a tree
T = (V,E), then there is a unique path that
connects a and b.
Proof. By contradiction.
Theorem 12.3 In any tree T = (V,E), |V| = |E| + 1.
Proof. By Mathematical Induction on |E|.
37
Properties of Trees (cont.)
Theorem 12.4 For every tree T = (V,E), if |V|  2, then T
has at least 2 vertices of degree 1.
deg( v)  2 | E | .
Proof. From Theorem 12.3 on

vV
Theorem 12.5 The following statements are equivalent for
a loop-free undirected graph G = (V,E).
(a) G is a tree.
(b) G is connected, but the removal of any edge from G
disconnects G into two subgraphs that are trees.
(c) G contains no cycles, and |V| = |E| + 1.
(d) G is connected, and |V| = |E| + 1.
38
Brainstorm
將1~9數字填入九個圓圈中,相鄰的數字(有邊連
結)之差不能小於3。數字不能重複,題目已經
預填兩個數。
8
6
39
Brainstorm
根據已故的麻省理工( MIT )哲學及邏輯家George Boolos,
以下的趣味邏輯問題可算是全世界最難的一個。
有甲、乙、丙三位精靈,其中一位只說真話,另外一位只說
假話,還有一位隨機地決定何時說真話,何時說假話。你
可以向這三位精靈發問三個是非題,而你的任務是從他們
的答案找出誰說真話,誰說假話,誰是隨機答話。你每次
可選擇任何一位精靈問話,問的問題可以取決於上一題的
答案。這個難題困難的地方是這些精靈會以「Da」或「Ja」
回答,但你並不知道它們的意思,只知道其中一個字代表
「對」,另外一個字代表「錯」。你應該問那三個問題呢?
答案見 Boolos (1998) Logic, Logic, and Logic Harvard
University Press, 弟29章.
40
Download