Discrete-Chapter 11 Graphs Part III

5
16 มหาวิทยาลัยราชภัฏสวนสุนันทา (ภาคการศึกษาที2/2555) เรียบเรียงโดย .วงศ์ยศ เกิดศรี CSC1001 Discrete Mathematics 11 - Graphs 1. Paths and Connectivity Example 23 (4 points) Graph G 1 and G 2 are connected or disconnected, and can you show a path from vertex a to g, a path from vertex b to e of graph G 1 Connectivity of Graphs 4 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 e 1 , . . . , e n of G for which there exists a sequence x 0 = u, x 1 , . . . , x n -1 , x n = v of vertices such that e i has, for i = 1, . . . , n, the endpoints x i -1 and x i . When the graph is simple, we denote this path by its vertex sequence x 0 , x 1 , . . . , x n (because 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 x 1 , x 2 , . . . , x n -1 or traverse the edges e 1 , e 2 , . . . , e n . A path or circuit is simple if it does not contain the same edge more than once. Definition 1 An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph. An undirected graph that is not connected is called disconnected. We say that we disconnect a graph when we remove vertices or edges, or both, to produce a disconnected subgraph. Definition 2 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 e 1 , e 2 , . . . , e n of G such that e 1 is associated with (x 0 , x 1 ), e 2 is associated with (x 1 , x 2 ), and so on, with e n associated with (x n -1 , x n ), where x 0 = u and x n = v. When there are no multiple edges in the directed graph, this path is denoted by its vertex sequence x 0 , x 1 , x 2 , . . . , x n . 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. Definition 3

description

 

Transcript of Discrete-Chapter 11 Graphs Part III

Page 1: Discrete-Chapter 11 Graphs Part III

16

มหาวิทยาลยัราชภฏัสวนสนุนัทา (ภาคการศึกษาท่ี 2/2555) เรยีบเรยีงโดย อ.วงศย์ศ เกิดศร ี

CSC1001 Discrete Mathematics 11 - Graphs

1. Paths and Connectivity

Example 23 (4 points) Graph G1 and G2 are connected or disconnected, and can you show a path from vertex a to g, a path from vertex b to e of graph G1

Connectivity of Graphs 4

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, . . . , en of G for which there exists a sequence x0 = u, 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 (because 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.

Definition 1

An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph. An undirected graph that is not connected is called disconnected. We say that we disconnect a graph when we remove vertices or edges, or both, to produce a disconnected subgraph.

Definition 2

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.

Definition 3

Page 2: Discrete-Chapter 11 Graphs Part III

17

มหาวิทยาลยัราชภฏัสวนสนุนัทา (ภาคการศึกษาท่ี 2/2555) เรยีบเรยีงโดย อ.วงศย์ศ เกิดศร ี

CSC1001 Discrete Mathematics Graphs - 11

Example 24 (4 points) Are the directed graphs G and H strongly connected? Are they weakly connected? Show a path from vertex b to a of graph G and show a path from vertex c to a of graph H.

2. Euler Paths and Circuits

Example 25 (4 points) Which of the undirected graphs have an Euler circuit? which have an Euler path?

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 4

A directed graph is weakly connected if there is a path between every two vertices in the underlying undirected graph.

Definition 5

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.

Definition 6

A connected multigraph with at least two vertices has an Euler circuit if and only if each of its vertices has even degree.

Definition 7

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

Definition 8

Page 3: Discrete-Chapter 11 Graphs Part III

18

มหาวิทยาลยัราชภฏัสวนสนุนัทา (ภาคการศึกษาท่ี 2/2555) เรยีบเรยีงโดย อ.วงศย์ศ เกิดศร ี

CSC1001 Discrete Mathematics 11 - Graphs

Example 26 (4 points) Which of the directed graphs have an Euler circuit? which have an Euler path?

3. Hamilton Paths and Circuits

Example 27 (3 points) Which of the simple graphs have a Hamilton circuit or, if not, a Hamilton path?

Example 28 (2 points) This simple graphs has a Hamilton circuit or, if not, a Hamilton path?

A simple path in a graph G that passes through every vertex exactly once is called a Hamilton path, and a simple circuit in a graph G that passes through every vertex exactly once is called a Hamilton circuit. That is, the simple path x0, x1, . . . , xn-1, xn in the graph G = (V ,E) is a Hamilton path if V = {x0, x1, . . . , xn-1, xn} and xi = xj for 0 ≤ i < j ≤ n, and the simple circuit x0, x1, . . . , xn-1, xn, x0 (with n > 0) is a Hamilton circuit if x0, x1, . . . , xn-1, xn is a Hamilton path.

Definition 9

DIRAC’S THEOREM 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.

Definition 10

Page 4: Discrete-Chapter 11 Graphs Part III

19

มหาวิทยาลยัราชภฏัสวนสนุนัทา (ภาคการศึกษาท่ี 2/2555) เรยีบเรยีงโดย อ.วงศย์ศ เกิดศร ี

CSC1001 Discrete Mathematics Graphs - 11

4. Shortest-Path

Using Dijkstra’s Algorithm to find a shortest path from a to z

The Dijkstra’s Algorithm

procedure Dijkstra(G: positive weighted connected simple graph) { /* G has vertices a = v0, v1, … , vn = z and lengths w(vi, vj) where w(vi, vj) = ∞ if {vi, vj} is not an edge in G */ for i = 1 to n { L(vi) = ∞ } L(a) = 0 S = ∅ /* the labels are now initialized so that the label of a is 0 and all other labels are ∞, and S is the empty set */ while z ∈ S { u = a vertex not in S with L(u) minimal S = S ∪ {u} for all vertices v not in S { if L(u) + w(u, v) < L(v) then L(v) = L(u) + w(u, v) { /* this adds a vertex to S with minimal label and updates the labels of vertices not in S */ } } } return L(z) /* L(z) = length of a shortest path from a to z */ }

Definition 11

Page 5: Discrete-Chapter 11 Graphs Part III

20

มหาวิทยาลยัราชภฏัสวนสนุนัทา (ภาคการศึกษาท่ี 2/2555) เรยีบเรยีงโดย อ.วงศย์ศ เกิดศร ี

CSC1001 Discrete Mathematics 11 - Graphs

Example 29 (5 points) Find the length of a shortest path between a and z in the given weighted graph.

Example 30 (5 points) Find the length of a shortest path between a and z in the given weighted graph.

Example 31 (5 points) Find the length of a shortest path between a and z in the given weighted graph.