Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Discrete-Chapter 11 Graphs Part III

585

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
585
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
22
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. 16 CSC1001 Discrete Mathematics 11 - Graphs 4 Connectivity of Graphs1. Paths and Connectivity 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, . . . , 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 2 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.Example 23 (4 points) Graph G1 and G2 are connected or disconnected, and can you show a path fromvertex a to g, a path from vertex b to e of graph G1 Definition 3 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.มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
• 2. Graphs - 11 CSC1001 Discrete Mathematics 17 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 two vertices in the underlying undirected graph.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 Definition 6 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 7 A connected multigraph with at least two vertices has an Euler circuit if and only if each of its vertices has even degree. Definition 8 A connected multigraph has an Euler path but not an Euler circuit if and only if it has exactly two vertices of odd degree.Example 25 (4 points) Which of the undirected graphs have an Euler circuit? which have an Euler path?มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
• 3. 18 CSC1001 Discrete Mathematics 11 - GraphsExample 26 (4 points) Which of the directed graphs have an Euler circuit? which have an Euler path?3. Hamilton Paths and Circuits Definition 9 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 10 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.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?มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
• 4. Graphs - 11 CSC1001 Discrete Mathematics 194. Shortest-Path Definition 11 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 */ }Using Dijkstra’s Algorithm to find a shortest path from a to zมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
• 5. 20 CSC1001 Discrete Mathematics 11 - GraphsExample 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.มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี