Chapter 7. Graphs
Chapter 7. Graphs
Chapter 7. Graphs
Contents
Contents
Contents
Contents
Contents
Contents
Definition
Definition
Simple directed graph has no loops and has no multiple directed edges
Simple directed graph has no loops and has no multiple directed edges
Graph Terminology
Basic Terminology
Basic Terminology
Basic Terminology
Basic Terminology
Basic Terminology
Example.
Example.
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
2m = ∑ deg (v )
v ∈V
(Note that this applies even if multiple edges and loops are present.)
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?
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.
Theorem
Definition
Definition
Example.
Find the in-degree and out-degree of each vertex in the graph G with
directed edges shown in Figure
Theorem
∑ deg − (v ) = ∑ deg + (v ) = |E |
v ∈V v ∈V
Example
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.
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
Example
A non-Bipartite
Theorem
Example
Example
Example
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.
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
Solution
Adjacency Matrices
Adjacency Matrices
Solution
Adjacency Matrices
Solution
Adjacency Matrices
Solution
Example
Solution
Example.
Solution
Example.
Show that the graphs G = (V, E) and H = (W, F), displayed in this figure, are
isomorphic.
Example.
Show that the graphs displayed in this figure are not isomorphic
Example
Example.
Example.
• a, d, c, f , e is a
Example.
• a, d, c, f , e is a
Example.
Example.
Example.
Example.
Example.
Example.
Example.
Theorem
CONNECTED COMPONENTS
CONNECTED COMPONENTS
Example
Definition
• Cut vertex (articulation point) (điểm cắt,đỉnh khớp): It’s removal will
produce disconnected subgraph from original connected graph.
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.
Example
Find the cut vertices and cut edges in the graph shown in the figure:
Example.
Example.
• G is strongly connected
Example.
• G is strongly connected
Example.
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.
Example
Using paths and circuits to determine whether two graphs are isomorphic:
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.
Example
How many paths of length four are there from a to d in the simple graph G
in this figure
Solution
Solution
Solution
• Thus, we have
Solution
• Thus, we have
Solution
• Thus, we have
Solution
• Thus, we have
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 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.
Examples
Example
Example
Theorem
Theorem
Examples
The graph
Examples
The graph
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).
Example
The graph
Example
The graph
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).
Examples
The graph
Examples
The graph
Examples
Examples
Examples
Examples
The graph G3
Examples
The graph G3
Example
Example
Theorem
Theorem
Graphs that have a number assigned to each edge are called weighted
graphs.
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.
Dijkstra’s Algorithm
Dijkstra’s Algorithm
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
Solution
Solution
Solution
Solution
Solution
Solution
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 }
Theorem
Theorem
Example.
Find the length of a shortest path between a and z in the given weighted
graph.
Example.
Find the length of a shortest path between a and z in the given weighted
graph.
Example.
Find the length of a shortest path between a and z in the given weighted
graph.