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

Chapter 7. Graphs

The document outlines the contents of Chapter 7 on graphs, which includes sections on graph models and terminology, representing graphs, connectivity, Euler and Hamilton paths, and shortest path problems. It defines what a graph is comprised of and provides examples of different types of graphs such as directed vs undirected, simple vs multigraphs. Basic graph terminology is also mentioned.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Chapter 7. Graphs

The document outlines the contents of Chapter 7 on graphs, which includes sections on graph models and terminology, representing graphs, connectivity, Euler and Hamilton paths, and shortest path problems. It defines what a graph is comprised of and provides examples of different types of graphs such as directed vs undirected, simple vs multigraphs. Basic graph terminology is also mentioned.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 178

Graphs... Graph Terminology... Representing Graphs Connectivity Euler and...

Shortest Path Problems

Chapter 7. Graphs

Mai Van Duy

Ngày 4 tháng 8 năm 2022

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Contents

1. Graphs and Graph Models

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Contents

1. Graphs and Graph Models


2. Graph Terminology and Special Types of Graphs

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Contents

1. Graphs and Graph Models


2. Graph Terminology and Special Types of Graphs
3. Representing Graphs and Graph Isomorphism

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Contents

1. Graphs and Graph Models


2. Graph Terminology and Special Types of Graphs
3. Representing Graphs and Graph Isomorphism
4. Connectivity

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Contents

1. Graphs and Graph Models


2. Graph Terminology and Special Types of Graphs
3. Representing Graphs and Graph Isomorphism
4. Connectivity
5. Euler and Hamilton Paths

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Contents

1. Graphs and Graph Models


2. Graph Terminology and Special Types of Graphs
3. Representing Graphs and Graph Isomorphism
4. Connectivity
5. Euler and Hamilton Paths
6. Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Definition

A graph G = (V, E) consists of V, a nonempty set of vertices (đỉnh) (or nodes)


and E, a set of edges (cạnh). Each edge has either one or two vertices
associated with it, called its endpoints (đầu mút). An edge is said to
connect its endpoints.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Definition

A graph G = (V, E) consists of V, a nonempty set of vertices (đỉnh) (or nodes)


and E, a set of edges (cạnh). Each edge has either one or two vertices
associated with it, called its endpoints (đầu mút). An edge is said to
connect its endpoints.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Simple graph: No two edges connect the same pair of vertices

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Simple graph: No two edges connect the same pair of vertices

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Multigraph: Multiple edges connect the same pair of vertices

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Multigraph: Multiple edges connect the same pair of vertices

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Pseudograph: Multigraph may have loops (khuyên,vòng)

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Pseudograph: Multigraph may have loops (khuyên,vòng)

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Undirected graph: Each edge has no direction

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Undirected graph: Each edge has no direction

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

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


and a set of directed edges (or arcs) E. Each directed edge is associated
with an ordered pair of vertices. The directed edge associated with the
ordered pair (u, v) is said to start at u and end at v.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Simple directed graph has no loops and has no multiple directed edges

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

Simple directed graph has no loops and has no multiple directed edges

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

• Directed multigraphs(or multiple directed edges): have multiple


directed edges from a vertex to a second (possibly the same) vertex.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

• Directed multigraphs(or multiple directed edges): have multiple


directed edges from a vertex to a second (possibly the same) vertex.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some kind of Graphs

• Directed multigraphs(or multiple directed edges): have multiple


directed edges from a vertex to a second (possibly the same) vertex.

• Mixed graph: A graph with both directed and undirected edges.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Graph Terminology

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Basic Terminology

• Two vertices u and v in an undirected graph G are called adjacent (or


neighbors)(kề nhau) in G if u and v are endpoints of an edge e of G.
Such an edge e is called incident (liên thuộc) with the vertices u and v
and e is said to connect u and v.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Basic Terminology

• Two vertices u and v in an undirected graph G are called adjacent (or


neighbors)(kề nhau) in G if u and v are endpoints of an edge e of G.
Such an edge e is called incident (liên thuộc) with the vertices u and v
and e is said to connect u and v.
• 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).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Basic Terminology

• Two vertices u and v in an undirected graph G are called adjacent (or


neighbors)(kề nhau) in G if u and v are endpoints of an edge e of G.
Such an edge e is called incident (liên thuộc) with the vertices u and v
and e is said to connect u and v.
• 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).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Basic Terminology

• Two vertices u and v in an undirected graph G are called adjacent (or


neighbors)(kề nhau) in G if u and v are endpoints of an edge e of G.
Such an edge e is called incident (liên thuộc) with the vertices u and v
and e is said to connect u and v.
• 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).
Notes.
• A vertex of degree zero is called isolated (đỉnh cô lập)

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Basic Terminology

• Two vertices u and v in an undirected graph G are called adjacent (or


neighbors)(kề nhau) in G if u and v are endpoints of an edge e of G.
Such an edge e is called incident (liên thuộc) with the vertices u and v
and e is said to connect u and v.
• 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).
Notes.
• A vertex of degree zero is called isolated (đỉnh cô lập)
• A vertex is pendant (đỉnh treo) if and only if it has degree one.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

What are the degrees of the vertices in the graphs G and H.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

What are the degrees of the vertices in the graphs G and H.

Solutions: Graph G:
deg(a)=2,deg(b)=4,deg(c)=4,deg(d)=1,deg(f)=4,deg(e)=3,deg(g)=0.
Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem (The HANDSHAKING Theorem)

Let G = (V , E ) be an undirected graph with m edges. Then

2m = ∑ deg (v )
v ∈V

(Note that this applies even if multiple edges and loops are present.)

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem (The HANDSHAKING Theorem)

Let G = (V , E ) be an undirected graph with m edges. Then

2m = ∑ deg (v )
v ∈V

(Note that this applies even if multiple edges and loops are present.)
Example. How many edges are there in a graph with 10 vertices each of
degree six?

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem (The HANDSHAKING Theorem)

Let G = (V , E ) be an undirected graph with m edges. Then

2m = ∑ deg (v )
v ∈V

(Note that this applies even if multiple edges and loops are present.)
Example. How many edges are there in a graph with 10 vertices each of
degree six?
Solution. 2m = 10.6 =⇒ m = 30.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

An undirected graph has an even number of vertices of odd degree.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Definition

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

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Definition

• 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.
• In a graph with directed edges the in-degree of a vertex v, denoted by
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.)

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Find the in-degree and out-degree of each vertex in the graph G with
directed edges shown in Figure

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

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

∑ deg − (v ) = ∑ deg + (v ) = |E |
v ∈V v ∈V

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

In the previous example, we have

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

A complete graph on n vertices, denoted by Kn , is a simple graph that


contains exactly one edge between each pair of distinct vertices.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

A complete graph on n vertices, denoted by Kn , is a simple graph that


contains exactly one edge between each pair of distinct vertices.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

A cycle Cn , n ≥ 3, consists of n vertices v1 , v2 , ..., vn and edges


{v1 , v2 }, {v2 , v3 }, ..., {vn−1 , vn }, and {vn , v1 }.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

A cycle Cn , n ≥ 3, consists of n vertices v1 , v2 , ..., vn and edges


{v1 , v2 }, {v2 , v3 }, ..., {vn−1 , vn }, and {vn , v1 }.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

We obtain a wheel Wn when we add an additional vertex to a cycle Cn , for


n ≥ 3, and connect this new vertex to each of the n vertices in Cn , by new
edges.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

We obtain a wheel Wn when we add an additional vertex to a cycle Cn , for


n ≥ 3, and connect this new vertex to each of the n vertices in Cn , by new
edges.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

An n-dimensional hypercube (khối n-chiều), or n-cube, denoted by Qn , is a


graph that has vertices representing the 2n bit strings of length n. Two
vertices are adjacent if and only if the bit strings that they represent differ in
exactly one bit position.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

An n-dimensional hypercube (khối n-chiều), or n-cube, denoted by Qn , is a


graph that has vertices representing the 2n bit strings of length n. Two
vertices are adjacent if and only if the bit strings that they represent differ in
exactly one bit position.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

A simple graph G is called bipartite (phân đôi) if its vertex set V can be
partitioned into two 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 two vertices in V1 or two vertices in V2 ). When this condition
holds, we call the pair (V1 , V2 ) a bipartition of the vertex set V of G.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Some special simple Graphs

A simple graph G is called bipartite (phân đôi) if its vertex set V can be
partitioned into two 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 two vertices in V1 or two vertices in V2 ). When this condition
holds, we call the pair (V1 , V2 ) a bipartition of the vertex set V of G.
Example. Bipartite Graphs

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

A non-Bipartite

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

A simple graph is bipartite if and only if it is possible to assign one of two


different colors to each vertex of the graph so that no two adjacent
vertices are assigned the same color.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Are the graphs G and H displayed in the Figure bipartite?

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Are the graphs G and H displayed in the Figure bipartite?

Solution. G: Biparite ({a,b,d},{c,e,f,g});


Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Are the graphs G and H displayed in the Figure bipartite?

Solution. G: Biparite ({a,b,d},{c,e,f,g});H: Non-Bipatite.


Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency list

An adjacency list is a list such that for each vertex u in the graph, it shows
the list of vertices v in which there is an edge between u and v.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency list

An adjacency list is a list such that for each vertex u in the graph, it shows
the list of vertices v in which there is an edge between u and v.
Example 1. Use adjacency lists to describe the simple graph given in Figure

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency Matrices

An adjacency matrix of a graph G with n vertices is a n × n matrix A = [aij ],


where (
1, if {vi , vj } is an edge of G
aij =
0, otherwise

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency Matrices

An adjacency matrix of a graph G with n vertices is a n × n matrix A = [aij ],


where (
1, if {vi , vj } is an edge of G
aij =
0, otherwise
Example. Use an adjacency matrix to represent the graph shown in this
figure:

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency matrices for undirected graphs with loops and


multiple edges

An adjacency matrices for undirected n-vertex graphs with loops and


multiple edges is the n × n matrix A = [aij ], where aij is the number of edges
that are associated to {vi , vj }.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency Matrices

Example. Use an adjacency matrix to represent the pseudograph shown in


Figure

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Adjacency Matrices

Example. Draw a graph with the adjacency matrix

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Incidence Matrices (ma trận liên thuộc)

An incidence matrices of a graph with n vertices and m edges is a n × m


matrix M = [mij ], where
(
1, when edge ej is incident with vi
mij =
0, otherwise

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Represent the graph shown in Figure with an incidence matrix.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Represent the graph shown in Figure with an incidence matrix

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Isomorphism of Graphs (đẳng cấu đồ thị)

The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if there


exists 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. Two simple
graphs that are not isomorphic are called non-isomorphic.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Isomorphism of Graphs (đẳng cấu đồ thị)

The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if there


exists 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. Two simple
graphs that are not isomorphic are called non-isomorphic.
Notes. Two Simple Graphs are isomorphic then they have:
• The same number of vertices,

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Isomorphism of Graphs (đẳng cấu đồ thị)

The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if there


exists 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. Two simple
graphs that are not isomorphic are called non-isomorphic.
Notes. Two Simple Graphs are isomorphic then they have:
• The same number of vertices,
• The same number of edges,

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Isomorphism of Graphs (đẳng cấu đồ thị)

The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if there


exists 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. Two simple
graphs that are not isomorphic are called non-isomorphic.
Notes. Two Simple Graphs are isomorphic then they have:
• The same number of vertices,
• The same number of edges,
• The same degrees of the vertices (deg(v)=deg[f(v)]).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Show that the graphs G = (V, E) and H = (W, F), displayed in this figure, are
isomorphic.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Show that the graphs displayed in this figure are not isomorphic

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Determine whether the graphs shown in Figure are isomorphic.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Paths (đường đi)

Let n be a nonnegative integer and G an undirected graph.


• A path (đường đi) of length n from u to v in G is a sequence of n edges
e1 , ..., en of G for which there exists a sequence u = x0 , x1 , ..., xn−1 , xn = v
of vertices such that ei has, for i = 1, ..., n, the endpoints xi −1 and xi .
When the graph is simple, we denote this path by its vertex sequence
x0 , x1 , ..., xn .

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Paths (đường đi)

Let n be a nonnegative integer and G an undirected graph.


• A path (đường đi) of length n from u to v in G is a sequence of n edges
e1 , ..., en of G for which there exists a sequence u = x0 , x1 , ..., xn−1 , xn = v
of vertices such that ei has, for i = 1, ..., n, the endpoints xi −1 and xi .
When the graph is simple, we denote this path by its vertex sequence
x0 , x1 , ..., xn .
• The path is a circuit (chu trình) if it begins and ends at the same vertex.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Paths (đường đi)

Let n be a nonnegative integer and G an undirected graph.


• A path (đường đi) of length n from u to v in G is a sequence of n edges
e1 , ..., en of G for which there exists a sequence u = x0 , x1 , ..., xn−1 , xn = v
of vertices such that ei has, for i = 1, ..., n, the endpoints xi −1 and xi .
When the graph is simple, we denote this path by its vertex sequence
x0 , x1 , ..., xn .
• The path is a circuit (chu trình) if it begins and ends at the same vertex.
• A path or circuit is simple (đơn) if it does not contain the same edge
more than once.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is not a path.
• b, c, f , e, b is

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is not a path.
• b, c, f , e, b is

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is not a path.
• b, c, f , e, b is a circuit of length 4.
• The path a, b, e, d, a, b, which is of length 5,

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is not a path.
• b, c, f , e, b is a circuit of length 4.
• The path a, b, e, d, a, b, which is of length 5,

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• a, d, c, f , e is a simple path of length 4.


• d, e, c, a is not a path.
• b, c, f , e, b is a circuit of length 4.
• The path a, b, e, d, a, b, which is of length 5,is not simple because it
contains the edge a, b twice.
Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Paths (đường đi)

Let n be a nonnegative integer and G a directed graph. A path of length n


from u to v in G is a sequence of edges e1 , e2 , ..., en of G such that e1 is
associated with (x0 , x1 ), e2 is associated with (x1 , x2 ), and so on, with en
associated with (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 , x2 , ..., 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 if it does not contain the same edge more
than once.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness (liên thông) In Undirected Graphs

Definition. An undirected graph is called connected if there is a path


between every pair of distinct vertices of the graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness (liên thông) In Undirected Graphs

Definition. An undirected graph is called connected if there is a path


between every pair of distinct vertices of the graph.
Example.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness (liên thông) In Undirected Graphs

Definition. An undirected graph is called connected if there is a path


between every pair of distinct vertices of the graph.
Example.

G1 is connected and G2 is disconnected.


Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

There is a simple path between every pair of distinct vertices of a


connected undirected graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

CONNECTED COMPONENTS

• A connected component (thành phần liên thông) of a graph G is a


connected subgraph of G that is not a proper subgraph of another
connected subgraph of G. That is, a connected component of a
graph G is a maximal connected subgraph of G.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

CONNECTED COMPONENTS

• A connected component (thành phần liên thông) of a graph G is a


connected subgraph of G that is not a proper subgraph of another
connected subgraph of G. That is, a connected component of a
graph G is a maximal connected subgraph of G.
• A graph G that is not connected has two or more connected
components that are disjoint and have G as their union(hợp).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Definition

• Cut vertex (articulation point) (điểm cắt,đỉnh khớp): It’s removal will
produce disconnected subgraph from original connected graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Definition

• Cut vertex (articulation point) (điểm cắt,đỉnh khớp): It’s removal will
produce disconnected subgraph from original connected graph.
• Cut edge (bridge) (cạnh cắt, cầu): It’s removal will produce subgraphs
which are more connected components than in the original graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Find the cut vertices and cut edges in the graph shown in the figure:

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness In Directed Graphs

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

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness In Directed Graphs

• 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.
• A directed graph is weakly connected if and only if there is always a
path between two vertices when the directions of the edges are
disregarded (underlying undirected).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness In Directed Graphs

• 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.
• A directed graph is weakly connected if and only if there is always a
path between two vertices when the directions of the edges are
disregarded (underlying undirected).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Connectedness In Directed Graphs

• 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.
• A directed graph is weakly connected if and only if there is always a
path between two vertices when the directions of the edges are
disregarded (underlying undirected).
Notes: Any strongly connected directed graph is also weakly connected.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• G is strongly connected

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• G is strongly connected

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

• G is strongly connected (→ weakly connected).


• H is not strongly connected (there is no directed path from a to b in this
graph).
Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Path and Isomorphism

If two graphs are isomorphism, then they have the same number of simple
circuits of length k, where k is some positive integer greater than 2.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Using paths and circuits to determine whether two graphs are isomorphic:

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Using paths and circuits to determine whether two graphs are isomorphic:

H has a simple circuit with length 3 and G has a simple circuit with length 4.
Thus, they are not isomorphic.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Path and Isomorphism

Using path to determine whether two graphs are isomorphic

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Path and Isomorphism

Using path to determine whether two graphs are isomorphic

They are isomorphic.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Counting Paths Between Vertices

Theorem. Let G be a graph with adjacency matrix A with respect to the


ordering v1 , v2 , ..., vn of the vertices of the graph (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, equals
the (i, j )th entry of Ar .

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

How many paths of length four are there from a to d in the simple graph G
in this figure

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

• The adjacency matrix of G (ordering the vertices as a, b, c, d) is

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

• The adjacency matrix of G (ordering the vertices as a, b, c, d) is

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

• The adjacency matrix of G (ordering the vertices as a, b, c, d) is

• Thus, we have

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

• The adjacency matrix of G (ordering the vertices as a, b, c, d) is

• Thus, we have

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

• The adjacency matrix of G (ordering the vertices as a, b, c, d) is

• Thus, we have

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

• The adjacency matrix of G (ordering the vertices as a, b, c, d) is

• Thus, we have

• There are 8 paths of length four from a to d.


Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

The seven bridges of Konigsberg

The town of Konigsberg, Prussia (now called Kaliningrad and part of the
Russian republic),was divided into four sections by the branches of the
Pregel River. These four sections included the two regions on the banks
of the Pregel, Kneiphof Island, and the region between the two
branches of the Pregel. In the eighteenth century seven bridges
connected these regions. Figure depicts these regions and bridges.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

The seven bridges of Konigsberg

The town of Konigsberg, Prussia (now called Kaliningrad and part of the
Russian republic),was divided into four sections by the branches of the
Pregel River. These four sections included the two regions on the banks
of the Pregel, Kneiphof Island, and the region between the two
branches of the Pregel. In the eighteenth century seven bridges
connected these regions. Figure depicts these regions and bridges.
The townspeople took long walks through town on Sundays. They
wondered whether it was possible to start at some location in the town,
travel across all the bridges once without crossing any bridge twice,
and return to the starting point.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

The seven bridges of Konigsberg

The seven bridges of Konigsberg

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

The seven bridges of Konigsberg

The seven bridges of Konigsberg

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Multigraph model of the town of Konigsberg

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Euler Paths and Circuits

An Euler circuit in a graph G is a simple circuit containing every edge of G.


An Euler path in G is a simple path containing every edge of G.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

G1 has an Euler circuit: a,e,c,d,e,b,a

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

G2 : has no Euler circuit and also has no Euler path

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

G3 : has no Euler circuit but it has Euler path a,c,d,e,b,d,a,b

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

1. A connected multigraph with at least two vertices has an Euler circuit if


and only if each of its vertices has even degree.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

1. A connected multigraph with at least two vertices has an Euler circuit if


and only if each of its vertices has even degree.
2. A connected multigraph has an Euler path but not an Euler circuit if
and only if it has exactly two vertices of odd degree.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph

have deg (a ) = deg (b) = deg (c ) = deg (d ) = deg (e) = 2.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph

have deg (a ) = deg (b) = deg (c ) = deg (d ) = deg (e) = 2. So, there is an
Euler circuit, (e.g., a, b, e, d, c, e, a).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

The graph

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

The graph

have deg (a ) = deg (b) = deg (c ) = 3; deg (d ) = deg (e) = 2.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

The graph

have deg (a ) = deg (b) = deg (c ) = 3; deg (d ) = deg (e) = 2.So, there is an
Euler path (e.g., a, d, c, e, b, c, a, b).

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph

have neither Euler circuit nor Euler path.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Hamilton Paths and Circuits

• A simple path in a graph G that passes through every vertex exactly


once is called a Hamilton path.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Hamilton Paths and Circuits

• A simple path in a graph G that passes through every vertex exactly


once is called a Hamilton path.
• A simple circuit in a graph G that passes through every vertex exactly
once is called a Hamilton circuit.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

G1 has Hamilton circuit: a, b, c, d, e, a.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

G2 has no Hamilton circuit.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph G3

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Examples

The graph G3

has neither a Hamilton circuit nor a Hamilton path.


Mai Van Duy Chapter 7. Graphs
Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example

This graph has Hamilton path a,b,c,d,e,f.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

Sufficient conditions for the existence of Hamilton circuits


1. If G is a simple graph with n vertices with n ≥ 3 such that the degree of
every vertex in G is at least n/2, then G has a Hamilton circuit.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

Sufficient conditions for the existence of Hamilton circuits


1. If G is a simple graph with n vertices with n ≥ 3 such that the degree of
every vertex in G is at least n/2, then G has a Hamilton circuit.
2. If G is a simple graph with n vertices with n ≥ 3 such that
deg (u ) + deg (v ) ≥ n for every pair of nonadjacent vertices u and v in
G, then G has a Hamilton circuit.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Shortest path Problem

Graphs that have a number assigned to each edge are called weighted
graphs.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Shortest path Problem

Graphs that have a number assigned to each edge are called weighted
graphs.
A shortest path problem is the problem of finding the least total length path
between two vertices in a weighted graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

A weighted simple graph

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Dijkstra’s Algorithm

Dijkstra’s algorithm finds the length of a shortest path between a and z in


an undirected connected simple weighted graph. It proceeds by finding
the length of a shortest path from a to a first vertex, the length of a shortest
path from a to a second vertex, and so on, until the length of a shortest
path from a to z is found. The algorithm relies on a series of iterations. A
distinguished set of vertices is constructed by adding one vertex at each
iteration. A labeling procedure is carried out at each iteration. In this
labeling procedure, a vertex w is labeled with the length of a shortest path
from a to w that contains only vertices already in the distinguished set. The
vertex added to the distinguished set is one with a minimal label among
those vertices not already in the set.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Dijkstra’s Algorithm

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Use Dijkstra’s algorithm to find the length of a shortest path between the
vertices a and z in the weighted graph displayed in the figure

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Solution
L(a) L(b) L(c) L(d) L(e) L(z) S
0 ∞ ∞ ∞ ∞ ∞ ∅
0 ∞ ∞ ∞ ∞ ∞ {a }
4 2 ∞ ∞ ∞ {a, c }
3 10 12 ∞ {a, c, b}
8 12 ∞ {a, c, b, d }
10 14 {a, c, b, d, e}
13 {a, c, b, d, e, z }

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

1. Dijkstra’s algorithm finds the length of a shortest path between two


vertices in a connected simple undirected weighted graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Theorem

1. Dijkstra’s algorithm finds the length of a shortest path between two


vertices in a connected simple undirected weighted graph.
2. Dijkstra’s algorithm uses O (n2 ) operations (additions and comparisons)
to find the length of a shortest path between two vertices in a
connected simple undirected weighted graph with n vertices.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Find the length of a shortest path between a and z in the given weighted
graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Find the length of a shortest path between a and z in the given weighted
graph.

Mai Van Duy Chapter 7. Graphs


Graphs... Graph Terminology... Representing Graphs Connectivity Euler and... Shortest Path Problems

Example.

Find the length of a shortest path between a and z in the given weighted
graph.

Mai Van Duy Chapter 7. Graphs

You might also like