Discrete Mathematics and Its Application - Chapter 9
Discrete Mathematics and Its Application - Chapter 9
• Introduction to Graphs
(9.1)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2011
2
History
– Simple graph
– Multigraph
– Pseudograph
– Directed graph
– Directed multigraph
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
4
Introduction to Graphs (9.1) (cont.)
– Definition 1
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
5
Introduction to Graphs (9.1) (cont.)
– Definition 2:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
6
Introduction to Graphs (9.1) (cont.)
Detroit
Chicago
New York
San Fransisco
Washington
Denver
Los Angeles
A Computer network with multiple lines
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
7
Introduction to Graphs (9.1) (cont.)
– Definition 3:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
8
Introduction to Graphs (9.1) (cont.)
Detroit
Chicago
New York
San Fransisco
Washington
Denver
Los Angeles
A Computer network with diagnostic lines
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
9
Introduction to Graphs (9.1) (cont.)
– Definition 4:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
10
Introduction to Graphs (9.1) (cont.)
Detroit
Chicago
New York
San Fransisco
Host
Washington
Denver
– Definition 5:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
12
Introduction to Graphs (9.1) (cont.)
Detroit
Chicago
New York
San Fransisco
Washington
Denver
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
13
Introduction to Graphs (9.1) (cont.)
• Modeling graphs
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
14
Introduction to Graphs (9.1) (cont.)
Racoon
Owl
Hawk
Opossum Squirrel
Crow
Mouse
Woodpecker
Shrew
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
16
Introduction to Graphs (9.1) (cont.)
Linda Brian
An influence graph
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
17
Introduction to Graphs (9.1) (cont.)
– Example:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
18
Graph Terminology (9.2)
• Basic Terminology
– Definition 1:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
19
Graph Terminology (9.2) (cont.)
– Definition 2:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
– Example: What are the degrees of the vertices in
the graphs G and H?
b c d a b c
a f e g e d
G H
deg(a) 2
deg(b) deg(c) deg(f) 4 deg(a) 4
Solution: deg(b) deg(e) 6
In G deg(d) 1 In H
deg(e) 3 deg(c) 1
deg(d) 5
deg(g)
© by Kenneth Discrete
H. Rosen, 0 Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
21
Graph Terminology (9.2) (cont.)
– Theorem 1:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
22
Graph Terminology (9.2) (cont.)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
23
Graph Terminology (9.2) (cont.)
– Theorem 2:
Proof: Let V1 and V2 be the set of vertices of even degree and the set
of vertices of odd degree, respectively, in an undirected graph
G = (V,E). Then
2e deg( v ) deg( v ) deg( v ).
vV vV1 vV2
Since deg(v) is even for v V1, the first term in the right-hand side of
the last equality is even. Furthermore, the sum of the two terms on the
right-hand side of the last equality is even, since this sum is 2e.
Hence, the second term in the sum is also even. Since all the terms in
this sum are odd, there must be an even number of such terms. Thus,
there are an even number of vertices of odd degree.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
24
Graph Terminology (9.2) (cont.)
– Definition 3:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
25
Graph Terminology (9.2) (cont.)
– Definition 4:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
26
Graph Terminology (9.2) (cont.)
e f
– Theorem 3:
deg
vV
( v ) (v )| E | .
deg
vV
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
Chapter 9 (Part 2): Graphs
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2011
29
Graph Terminology (9.2) (cont.)
• Some special simple graphs
– Complete graph
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
30
Graph Terminology (9.2) (cont.)
K1 K2 K3 K4
– Cycles
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
32
Graph Terminology (9.2) (cont.)
C3 C4
The cycles
C5 C3, C4, C5 & C6
C6
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
33
Graph Terminology (9.2) (cont.)
– Wheels
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
34
Graph Terminology (9.2) (cont.)
W3 W4
– n-cubes
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
36
Graph Terminology (9.2) (cont.)
110 111
10 11 101
100
010
011
0 1 00 01 000 001
Q1 Q2 Q3
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
37
Graph Terminology (9.2) (cont.)
• Bipartite graph
– Definition 5:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
38
Graph Terminology (9.2) (cont.)
v3 v4
v5 v6
K2,3 K3,3
K3,5
K2,6
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
43
Graph Terminology (9.2) (cont.)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
44
Graph Terminology (9.2) (cont.)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
45
Representing Graphs & Graph Isomorphism
• Introduction
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
46 Representing Graphs & Graph
Isomorphism (9.3) (cont.)
• Representing Graph
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
47
Representing Graphs & Graph Isomorphism (9.3) (cont.)
e d
• Adjacency matrices
– To simplify computation, graphs can be
represented using matrices
• Adjacency matrix
• Incident matrix
c d
c
d
0 3 0 2
3 0 1 1
Solution: The adjacency matrix using
The ordering of vertices a, b, c, d is: 0 1 1 2
2 1 2 0
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
51
Representing Graphs & Graph Isomorphism (9.3) (cont.)
• Incidence matrices
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
52
Representing Graphs & Graph Isomorphism (9.3) (cont.)
v4 v5
e1 e2 e3 e4 e5 e6
v1 1 1 0 0 0 0
Solution: v2 0 0 1 1 0 1
v3 0 0 0 0 1 1
v4
1 0 1 0 0 0
v5 0 1 0 1 1 0
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
53
Representing Graphs & Graph Isomorphism (9.3) (cont.)
• Isomorphism of graphs
– Definition 1:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
55
Representing Graphs & Graph Isomorphism (9.3) (cont.)
u3 u4 v3 v4
G H
Solution: The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3,
f(u4) = v2 is a one-to-one correspondence between V and
W. To see that this correspondence preserves adjacency,
note that adjacent vertices in G are u1 and u2, u1 and u3,
u2 and u4, and u3 and u4, and each of the pairs f(u1) = v1
and f(u2) = v4, f(u1) = v1 and f(u3) = v3, f(u2) = v4 and
f(u3) = v3, and f(u1) = v1 and f(u4) = v2 are adjacent in H.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
56
Connectivity (9.4)
• Goal: determination of paths within graphs
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
57
Connectivity (9.4) (cont.)
• Path
– Definition 1:
Let n be a nonnegative integer and G an undirected
graph. A path of length n from u to v in G is a sequence of
n edges e1, e2, …, en of G such that f(e1) = {x0, x1},
f(e2) = {x1, x2}, …, f(en) = {xn-1, xn}, where x0 = u and xn = v.
When the graph is simple, we denote this path by its
vertex sequence x0, x1, …, xn (since listing these vertices
uniquely determines the path). The path is a circuit if it
begins and ends at the same vertex, that is, if u = v, and
has length greater than zero. The path or circuit is said to
pass through the vertices x1, x2, …, xn-1 or traverse the
edges e1, e2, …, en. A path or circuit is simple if it does not
contain the same edge more than once.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
58
Connectivity (9.4) (cont.)
– Example:
a b c
d e f
In this simple graph a, d, c, f, e is a simple path of
length 4, since {a,d}, {d,c}, {c,f}, and {f,e} are all
edges.
However, d, e, c, a is not a path, since {e,c} is not an
edge.
Note that b, c, f, e, b is a circuit of length 4 since
{b,c}, {c,f}, {f,e}, and {e,b} are edges, and this path
begins and ends at b.
The path a, b, e,d,a,b, which is of length 5, is not
simple since it contains the edge {a,b} twice.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
59
Connectivity (9.4) (cont.)
– Definition 2:
Let n be a nonnegative integer and G a directed
multigraph. A path of length n from u to v in G is a
sequence of edges e1, e2, …, en of G such that
f(e1) = (x0, x1), f(e2) = (x1, x2), …, f(en) = (xn-1, xn),
where x0 = u and xn = v. When there are no
multiple edges in the directed graph, this path is
denoted by its vertex sequence x0, x1, …, xn. A
path of length greater than zero that begins and
ends at the same vertex is called a circuit or
cycle. A path or circuit is called simple it it does
not contain the same edge more than once.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
60
Connectivity (9.4) (cont.)
– Question asked:
When does a computer network have the
property that every pair of computers can
share information, if message can be sent
through one or more intermediate
computers?
– Definition 3:
– Theorem 1:
Proof: Exercise!
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
62
Connectivity (9.4) (cont.)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
63
Connectivity (9.4) (cont.)
– Definition 4:
– Definition 5:
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
65
Connectivity (9.4) (cont.)
c c
G H
e d e d
Solution: G is strongly connected because there is a path
between any 2 vertices in this directed graph. Hence, G is
also weakly connected.
The graph H is not strongly connected. There is no directed
path from a to b in this graph. However, H is weakly
connected, since there is a path between any 2 vertices in
their underlying undirected graph of H.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
66
Connectivity (9.4) (cont.)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
67
Connectivity (9.4) (cont.)
G u3 H v3
u5 v5
u4 v4
Solution: Both G and H have 6 vertices and 8 edges. Each has 4
vertices of degree 3, and two vertices of degree 2. However, H has a
simple circuit of length 3, namely, v1, v2, v6, v1 whereas G has no
simple circuit of length 3, as can be determined by inspection (all
simple circuits in G have length at least four). Since the existence of a
simple circuit of length 3 is an isomorphic invariant, G and H are not
isomorphic.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
68
Connectivity (9.4) (cont.)
– Theorem 2:
Proof: Exercise!
Dr. Djamel © by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CSE 504 Discrete Structures & Foundations
69
Connectivity (9.4) (cont.)
a b
d c
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
70a b
Connectivity (9.4) (cont.)
d c
G
Solution: The adjacency matrix of G (ordering the vertices as a, b, c, d) is
0 1 1 0
1 0 0 1
A .
1 0 0 1
0 1 1 0
Hence, the number of paths of length 4 from a to d is the (1,4)th entry of
A4. Since 8 0 0 8
0 8 8 0
A
4 .
0 8 8 0
8 0 0 8
there are exactly 8 paths of length 4 from a to d. By inspection of the
graph, we see that a, b, a, b, d; a, b, a, c, d; a, b, d, b, d; a, b, d, c, d; a,
c, a, b, d; a, c, a, c, d; a, c, d, b, d; and a, c, d, c, d are the 8 paths from a
to d.
Dr. Djamel © by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CSE 504 Discrete Structures & Foundations