100% found this document useful (1 vote)
1K views70 pages

Discrete Mathematics and Its Application - Chapter 9

Uploaded by

Funkey dunkey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views70 pages

Discrete Mathematics and Its Application - Chapter 9

Uploaded by

Funkey dunkey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 70

Chapter 9 (Part 1): Graphs

• Introduction to Graphs
(9.1)

• Graph Terminology (9.2)

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2011
2
History

• Basic ideas were introduced in the eighteenth


century by Leonard Euler (Swiss mathematician)

• Euler was interested in solving the Königsberg


bridge problem (Town of Königsberg is in
Kaliningrad, Republic of Russia)

• Graphs have several applications in many areas:


– Study of the structure of the World Wide Web
– Shortest path between 2 cities in a transportation network
– Molecular chemistry
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
3
Introduction to Graphs (9.1)
• There are 5 main categories of graphs:

– 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

A simple graph G = (V,E) consists of V, a


nonempty set of vertices, and E, a set of
unordered pairs of distinct elements of V
called edges.

– Example: Telephone lines connecting


computers in different cities.

© 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:

A multigraph G = (V,E) consists of a set E of


edges, and a function f from E to {{u,v} | u, v
 V, u  v}. The edges e1 and e2 are called
multiple or parallel edges if f(e1) = f(e2).

– Example: Multiple telephone lines connecting


computers in different cities.

© 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:

A pseudograph G = (V,E) consists of a set V of


vertices, a set E of edges, and a function f from E
to {{u,v} | u, v  V}. An edge is a loop if f(e) = {u,u}
= {u} for some u  V.

© 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:

A directed graph (V,E) consists of a set of vertices


V and a set of edges E that are ordered pairs of
elements of V.

© 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

A Communication network with


Los Angeles one-way telephone lines
This example shows that the host computer can only
receive data from other computer, it cannot emit
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
11
Introduction to Graphs (9.1) (cont.)

– Definition 5:

A directed multigraph G = (V,E) consists of a


set V of vertices, a set E of edges, and a
function f from E to {{u,v} | u, v  V}. The
edges e1 and e2 are multiple edges if f(e1) =
f(e2).

© 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

Los Angeles A Computer network with multiple


one-way telephone lines

© 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

– Example: Competition between species in an


ecological system can be modeled using a
niche overlap graph.

An undirected edge connect two vertices if


the two species represented by these
vertices compete for food.

© 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

A niche overlap graph


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
15
Introduction to Graphs (9.1) (cont.)

– Example: Influence of one person in society

• A directed graph called an influence graph


is used to model this behavior

• There is a directed edge from vertex a to


vertex b if the person represented by a
vertex a influences the person
represented by vertex b.

© 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

Deborah Fred Yvonne

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:

The World Wide Web can be modeled as a


directed graph where each web page is
represented by a vertex and where an edge
connects 2 web pages if there is a link
between the 2 pages

© 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

– Goal: Introduce graph terminology in order to further


classify graphs

– Definition 1:

Two vertices u and v in an undirected graph G are called


adjacent (or neighbors) in G if {u,v} is an edge of G. If e =
{u,v}, the edge e is called incident with the vertices u and
v. The edge e is also said to connect u and v. The vertices
u and v are called endpoints of the edge {u,v}.

© 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:

The degree of a vertex in an undirected graph is


the number of edges incident with it, except that a
loop at a vertex contributes twice to the degree of
that vertex. The degree of the vertex v is denoted
by deg(v).

© 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:

The handshaking theorem


Let G = (V,E) be an undirected graph with e
edges. Then
2e   deg( v ).
vV
(Note that this applies even if multiple edges
& loops are present.)

© 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.)

– Example: How many edges are there in a


graph with ten vertices each of degree 6 ?

Solution: Since the sum of the degrees of the


vertices is 6*10 = 60  2e = 60. Therefore, e
= 30

© 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:

An undirected graph has an even number of vertices of


odd degree.

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 ).
vV vV1 vV2

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:

When (u,v) is an edge of the graph G with


directed edges, u is said to be adjacent to v
and v is said to be adjacent from u. The
vertex u is called the initial vertex of (u,v),
and v is called the terminal or end vertex of
(u,v). The initial vertex and terminal vertex of
a loop are the same.

© 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:

In a graph with directed edges the in-degree of a


vertex v, denoted deg-(v), is the number of edges
with v as their terminal vertex. The out-degree of
v, denoted by deg+(v), is the number of edges
with v as their initial vertex.
(Note that a loop at a vertex contributes 1 to both
the in-degree and the out-degree of this vertex)

© 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.)

– Example: Find the in-degree and the out-degree of each


vertex in the graph G
a b c

e f

Solution: The in-degree of G are: deg-(a) = 2, deg-(b) = 2,


deg-(c) = 3, deg-(d) = 2, deg-(e) = 3, and deg-(f) = 0.
The in-degree of G are: deg+(a) = 4, deg+(b) = 1, deg+(c) =
2, deg+(d) = 2, deg+(e) = 3, and deg+(f) = 0
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
27
Graph Terminology (9.2) (cont.)

– Theorem 3:

Let G = (V,E) be a graph with directed


edges. Then

 deg
vV

( v )   (v )| E | .
deg 

vV

© 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

• Graph Terminology (9.2) (cont.)


• Representing Graphs &
Graph Isomorphism (9.3)
• Connectivity (9.4)

© 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

They are denoted by Kn, they contain exactly


one edge between each pair of distinct
vertices

© 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

The graphs Kn for


K5 1n6
K6
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
31
Graph Terminology (9.2) (cont.)

– Cycles

They are denoted by Cn(n  3): they consist


of n vertices v1, v2, …, vn and edges {v1, v2},
{v2, v3}, …, {vn, vn-1} and {vn, v1}

© 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

They are denoted by Wn; they are obtained


by adding a vertex to the graphs Cn and
connect this vertex to all vertices

© 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

The Wheels W3,


W5 W4, W5 & W6
W6
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
35
Graph Terminology (9.2) (cont.)

– n-cubes

They are denoted by Qn, they are graphs that


have vertices representing the 2n bit strings
of length n.

Two vertices are adjacent if and only if the


bits strings that they represent differ in
exactly one bit position

© 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

The n-cube Qn for n = 1, 2, and 3.

© 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:

A simple graph is called bipartite if its vertex set V


can be partitioned into 2 disjoint sets V1 and V2
such that every edge in the graph connects a
vertex in V1 and a vertex in V2 (so that no edge in
G connects either 2 vertices in V1 or 2 vertices in
V2).

© 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.)

– Example: C6 is bipartite, since its vertex set can


be partitioned into the 2 sets V1 = {v1, v3, v5} and
V2 = {v2, v4, v6}, and every edge of C6 connects a
vertex in V1 and a vertex in V2.
V1 V2
v1 v2

v3 v4

v5 v6

– Example: K3 is not bipartite. Why?


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
39
Graph Terminology (9.2) (cont.)

– Characterization of bipartite graph


• A graph is bipartite if and only if it is possible to
color the vertices of the graph with at most 2
colors so that no 2 adjacent vertices have the
same color
• Example: Complete bipartite graphs: they are
denoted by Km,n. Their vertices set is
partitioned into 2 subsets of m and n vertices,
respectively. There is an edge between 2
vertices if and only if one vertex is in the first
subset and the other vertex is in the second
subset.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
40
Graph Terminology (9.2) (cont.)

K2,3 K3,3

K3,5
K2,6

Some complete bipartite graphs


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
41
Graph Terminology (9.2) (cont.)

• Some applications of special types of graphs

– Local area network


Goal: connecting computers as well as peripheral
devices in a building using a local area network
topology

– Some of these networks are based on a star


topology, where all devices are connected to a
central control device

– The star topology is equivalent to a K1,n complete


bipartite graph
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
42
Graph Terminology (9.2) (cont.)

– Other local area networks use a ring


topology  Cn graphs

– Finally, the hybrid topology which is


equivalent to a Wn graph is also used

© 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.)

(a) (b) (c)

Star, ring, and hybrid topologies for local area networks

© 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.)

– Interconnection networks for parallel


processing

• Linear arrays for processor connection

• Mesh network (Markovian neighborhood)

• Hypercube interconnection (generalization of n-


cubes)

© 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

– Goal: Consists of choosing the most


convenient representation of a graph

– We need to determine whether 2 graphs are


isomorphic, this problem is important in
graph theory

© 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

– List all the edges of the graph (no multiple


edges)

– Use adjacency list, which specifies the


vertices that are adjacent to each vertex of
the 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.)

– Example: Use adjacency lists to describe this


simple graph. b
a c

e d

Vertex Adjacent vertices


Solution: a b, c, e
b a
c a, d, e
d c, e
e Discrete Mathematics
© by Kenneth H. Rosen, a, c,&dits Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
48
Representing Graphs & Graph Isomorphism (9.3) (cont.)

• Adjacency matrices
– To simplify computation, graphs can be
represented using matrices

• Adjacency matrix
• Incident matrix

– The adjacency matrix is defined as A = [aij]


such that
1 if {v i , v j } is an edge of G
a ij  
 0 otherwise
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
49
Representing Graphs & Graph Isomorphism (9.3) (cont.)

– Example: Use a adjacency matrix to represent


this graph: a b

c d

Solution: We order the vertices a, b, c, d.


The matrix representing this graph is
0 1 1 1
1 0 1 0 

1 1 0 0
 
1 0 0 0
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
50
Representing Graphs & Graph Isomorphism (9.3) (cont.)

– In case of pseudographs , the adjacency matrix is


not a binary matrix but is formed of elements that
represent the number of edges between 2
vertices
– Example: Use an adjacency matrix to represent
this pseudograph: a b

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

– Let G = (V,E) be an undirected graph.

– Incidence matrices are defined by the matrix


M = [mij] such that

1 if edge e j is incident with vertex v i


m ij  
0 otherwise

© 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.)

– Example: Using an incidence matrix, represent


the following undirected graph:
v1 v2 e6 v3
e2
e4 e
e1 e3 5

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

– Goal: is it possible to draw 2 graphs in the same


way?

– In chemistry, different graph compounds can have


the same molecular formula but can differ in
structure

– The graphs of these compounds cannot be drawn in


the same way

– Graphs having the same structure share common


properties
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
54
Representing Graphs & Graph Isomorphism (9.3) (cont.)

– Definition 1:

The simple graphs G1 = (V1,E1) and G2 =


(V2,E2) are isomorphic if there is a one-to-
one and onto function f from V1 to V2 with the
property that a and b are adjacent in G1 if
and only if f(a) and f(b) are adjacent in G2, for
all a and b in V1. Such a function f is called
an isomorphism.

© 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.)

– Example: Show that the graphs G = (V,E) and


H = (W,F) are isomorphic
u1 u2 v1 v2

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

• Many problems can be modeled with paths


formed by traveling along the edges of graphs

• Some examples of problems are:

– Study the link between remote computers


– Efficient planning of routes for mail delivery
– Garbage pickup
– Diagnostic in computer networks

© 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.)

• Connectedness in undirected graphs

– 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?

– This question is equivalent to:


When is there always a path between 2
vertices in the graph?
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
61
Connectivity (9.4) (cont.)

– Definition 3:

An undirected graph is called connected if there is


a path between every pair of distinct vertices of
the graph

– Theorem 1:

There is a simple path between every pair of


distinct vertices of a connected undirected graph

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.)

– A graph that is not connected is the union of


two or more connected subgraphs, each pair
of which has no vertex in common.

– These disjoint connected subgraphs are


called the connected components of the
graph

© 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.)

• Connected in directed graphs

– Definition 4:

A directed graph is strongly connected if there is a path


from a to b and from b to a whenever a and b are vertices
in the graph

– Definition 5:

A directed graph is weakly connected if there is a path


between every 2 vertices in the underlying undirected
graph
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Dr. Djamel CSE 504 Discrete Structures & Foundations
64
Connectivity (9.4) (cont.)

– A directed graph is weakly connected 


there is always a path between 2 vertices
when the directions of the edges are ignored

– Strongly connected  weakly connected


directed graph

© 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.)

– Example: Are the directed graphs G and H


strongly connected?
a b a b

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.)

• Paths & isomorphism

– Paths and circuits can help determine


whether 2 graphs are isometric

– The existence of a simple circuit (or cycle) of


a particular length is a useful invariant to
show that 2 graphs are not isomorphic

© 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.)

– Example: Determine whether the graph G and H


are isomorphic. u1 v1
u6 u2 v6 v2

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.)

• Counting paths between vertices

– Theorem 2:

Let G be a graph with adjacency matrix A with


respect to the ordering v1, v2, …, vn (with directed
or undirected edges, with multiple edges and
loops allowed). The number of different paths of
length r from vi to vj, where r is a positive integer
is equals to the (i, j)th entry of Ar.

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.)

– Example: How many paths of length 4 are there


from a to d in the simple graph G?

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

You might also like