csnb143 – discrete structure topic 9 – graph. learning outcomes student should be able to...

22
CSNB143 – Discrete Structure Topic 9 – Graph

Upload: lesley-short

Post on 01-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

CSNB143 – Discrete Structure

Topic 9 – Graph

Page 2: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphLearning Outcomes• Student should be able to identify graphs and its components. • Students should know how to use certain ways to solve problems in

graphs.

Page 3: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphBasic Components of Graph• A graph G consist of a finite set V of objects called vertices , a finite set E

of objects called edges and a function , that assigns two vertices to each edge.

We will write graph as G = (V, E, ). • If e is an edge, and (e) = {v, w), that are vertices for e, we say e is an edge

between v and w. The vertices v and w are called the end points of e. • Usually, graphs are represented by pictures, using a point for each vertex

and a line for each edge, as below:

Page 4: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphBasic Components of Graph• The degree of a vertex is the number of edges connected to it. • Any edge that connects from a vertex to the same vertex, such as loop,

contributes 2 to the degree of a vertex. • A vertex with degree 0 is called an isolated vertex.• A pair of vertices that determine an edge, or sharing the same edge, are

adjacent vertices.• Example

Vertex A has degree 2, vertex B has degree 4, vertex C has degree 1, vertex D has degree 3, vertex E has degree 2.

Page 5: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphBasic Components of Graph• Work this out Find the degrees for all vertices in (b) and (c).

Can you identify any isolated vertex, adjacent vertices and non-adjacent vertices in (b)?

Page 6: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphBasic Components of Graph• A path in a graph G consists of a vertex sequence of : v1, v2, …, vk, each

one is adjacent to the next, and no edge occurs more than once. • In short, path is a journey from vertex v1 and travel through the edges to vk

without using any edge twice. • A circuit is a path that begins and ends at the same vertex. (circuit =

cycle). • A path is called simple if no vertex appears more than once in the vertex

sequence.

Page 7: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphBasic Components of Graph

• In (a), path 1: A, B, E, D, D; path 2: D, E, B, C and path 3: A, B, A. Note that in 3, we do not know which path between A and B has been used first.

• In (b), path 4: a, b, c, a; and 5: d, c, a, a, b. Path 4 is a cycle. Path 6: c, a, b, c, d is not simple.

• In (c), sequence 1, 2, 3, 2 is not a path, because the single edge between 2 and 3 has been traveled twice. Path 7: 4, 5, 6, 4 is a cycle.

Page 8: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphBasic Components of Graph• A graph is called connected if there is a path from any vertex to any vertex

in the graph. • If not, the graph is called disconnected. If the graph is disconnected, the

various connected pieces are called the components of the graph.

Graph (a) is connected. Graph (a) is connected. Graphs (b) and (c) are Graphs (b) and (c) are disconnected graphs. Graph disconnected graphs. Graph (c) has two components(c) has two components.

Page 9: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphSub graph• Let say G = (V, E, ) is a graph. Choose a subset E1 from E and subset V1

from V so that V1 contains all the end points of edges in E1. Then H = (V1, E1, 1) is also a graph where 1 is restricted to edges in E1.

• H is called the sub graph of G.• Example: (d), (e) and (f) are the sub graphs of (a).

Page 10: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphEuler Path and Circuit• A path in a graph G is called a Euler path if it includes EVERY EDGE exactly

once. • A Euler circuit is a Euler path that is a circuit.

Euler path exists in (a); E, D, B, A, C, D, but Euler circuit does not exist.

Euler circuit exist in (b); 5, 3, 2, 1, 3, 4, 5.

Page 11: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphEuler Path and Circuit• Example: Consider the floor plan as below. Each room is connected to

every room and to the outside. Is it possible to begin in a room or outside and take a walk that goes through each door exactly once?

Page 12: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphEuler Path and Circuit• When we are looking at a graph, is it possible to determine whether a

Euler path or Euler circuit exists without actually finding it? Theorem 1 (to identify a circuit)• If a graph G has a vertex of odd degree, there can be no Euler circuit in G. • If G is a connected graph and every vertex has even degree, then there is

a Euler circuit in G.

Page 13: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphEuler Path and CircuitTheorem 2 (to identify a path)• If a graph G has more than two vertices of odd degree, then there can be

no Euler path in G. • If G is connected and has exactly two vertices of odd degree, there is a

Euler path in G. The path must begin at one vertex of odd degree and end at the other.

Page 14: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – Graph

Page 15: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – Graph

Euler Path and Circuit• So the previous graph will be:

Degrees for the four vertices are: A = 4, B = 4, C = 5, D = 7. From Theorem 1, there is odd degree vertex, so, there is no Euler circuit. From Theorem 2, there are exactly two odd degree vertices, so there is a Euler path. It must begin from C/D and ends at D/C.

The path is: C, D, C, A, D, A, B, D, B, C, D

Page 16: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphEuler Path and Circuit• Work this out: Consider the graphs below, and find a Euler path or circuit.

Page 17: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – Graph

Page 18: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – Graph

Page 19: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphHamilton Path and Circuit• When we saw a graph, is it possible to determine whether a Hamilton

path or circuit exists or not? (WARNING: They don’t necessarily work !!)• Theorem 1:

Let G be a connected graph with n vertices, n > 2 and no loops or multiple edges, G has a Hamilton circuit if for any two vertices u and v of G that are not adjacent, the degree of u plus the degree of v is greater that or equal to n. D(u) + D(v) the number of vertices.

• Corollary 1 (outcome): G has a Hamilton circuit if each vertex has degree greater than or equal to n/2

Page 20: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphHamilton Path and Circuit• Theorem 2:

Let the number of edges of G be m. Then G has a Hamilton circuit if m ½ (n2 – 3n + 6) where n is the number of vertices.

Reminder: If Theorem failed, we cannot say that the graph has no Hamilton circuit. We have to check the circuit or path manually.

Page 21: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – Graph

Hamilton Path and Circuit• Example:

Take two non adjacent vertices; let say A and E. The sum of their degrees are (2 + 2) = 4 < 8 (number of vertices). But if we check properly in manual, we can have the Hamilton circuit that is A, B, C, D, E, F, G, H, A

Page 22: CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how

Topic 9 – GraphWork this outDetermine if the following graph has the Hamiltonian circuit and/or path. Discuss your answer