Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
-
date post
15-Jan-2016 -
Category
Documents
-
view
218 -
download
0
Transcript of Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
Discrete StructuresChapter 7B
GraphsNurul Amelina Nasharuddin
Multimedia Department
2
Objectives
On completion of this topic, student should be able to:
a. Explain basic terminology of a graph
b. Identify Euler and Hamiltonian cycle
c. Represent graphs using adjacency matrices
3
Seven Bridges of Königsberg
• Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once? NO
4
Terminology• Walk, path, simple path, circuit, simple circuit
• Walk from two vertices is a finite alternating sequence of adjacent vertices and edges
v0e1v1e2…envn
• Trivial walk from v to v consists of single vertex
• Closed walk – starts and ends at same vertex
5
Path
• Path – a walk that does not contain a repeated edge (may have a repeated vertex)
v0e1v1e2…envn where all the ei are distinct
• Simple path – a path that does not contain a repeated vertex (and no repeated edge)
v0e1v1e2…envn where all the ei and vj are distinct
6
Example - Path
• Path
v
• Simple path
w
7
Circuit
• Circuit – a closed walk without repeated edgev0e1v1e2…envn where ei are distinct and v0 = vn
• Simple circuit – a circuit with no repeated vertex except first and last
v0e1v1e2…envn where ei and vj are distinct and v0 = vn
8
Example - Circuit
• Circuit
• Simple circuit
9
Repeated edge? Repeated vertex? Starts and ends at the same point?
Walk Allowed Allowed Allowed
Path No Allowed Allowed
Simple Path No No No
Closed Walk Allowed Allowed Yes
Circuit No Allowed Yes
Simple Circuit No First and Last Only
Yes
10
Connectedness• Connectedness – if there is a walk from one to the
other• Let G be a graph. Two vertices v and w of G are
connected iff there is a walk from v to w• The graph G is connected iff given any two vertices
v and w in G, there is a walk from v to w
G is connected vertices, v, w V(G), a walk from v to w
11
Example - Connectedness
12
Euler Circuits
• A circuit that contains every vertex and every edge of G
• A sequence of adjacent vertices and edges that 1. starts and ends at the same vertex, 2. uses every vertex of G at least once, and 3. uses every edge of G exactly once
13
If a Graph has an Euler Circuit, every Vertex has Even Degree.
• Contrapositive: if some vertex has odd degree, then the graph does not have an Euler circuit.
14
Theorem: Euler Circuits• If a graph has an Euler Circuit, every vertex has even
degreeContrapositive: if some vertex has odd degree, then the graph does not have an Euler circuit.
• If every vertex of nonempty graph has even degree and if graph is connected, then the graph has an Euler circuit
15
Theorem: Euler Circuits
• A graph G has an Euler circuit if, and only if, G is connected and every vertex of G has even degree
16
Hamiltonian Circuit• A simple circuit that includes every vertex of G
• A sequence of adjacent vertices and distinct edges in which every vertex of G appears exactly once, except for the first and last, which are the same
17
Hamiltonian Circuit
• An Euler circuit for a graph G may not be a Hamiltonian circuit
• A Hamiltonian circuit may not be an Euler circuit• Proved simple criterion for determining whether a
graph has an Euler circuit• No analogous criterion for determining whether a
graph has a Hamiltonian circuit• Nor is there an efficient algorithm for finding such an
algorithm
18
Hamiltonian Circuit
• Finding Hamiltonian circuits
19
Traveling Salesman Problem
http://en.wikipedia.org/wiki/Traveling_Salesman_Problem
20
Objectives
On completion of this topic, student should be able to:
a. Explain basic terminology of a graph
b. Identify Euler and Hamiltonian cycle
c. Represent graphs using adjacency matrices
21
Matrices and Directed Graph
• Let G be a directed graph with ordered vertices v1,v2,…,vn
• The adjacency matrix of G is the n x n matrix, A =(aij) over the set of nonnegative integers such that
aij = the numbers of arrows from vi to vj
for all i,j = 1,2,…,n.
22
Examples
• Adjacency matrix of a graph (Example 11.3.2)
• Obtaining a directed graph from a matrix (Example 11.3.3)
23
Matrices and (Undirected) Graphs
• Let G be a (undirected) graph with ordered vertices v1,v2,…,vn
• The adjacency matrix of G is the n x n matrix A =(aij) over the set of nonnegative integers such that
aij = the numbers of edges connecting vi and vj
for all i,j = 1,2,…,n
24
Examples
• Finding the adjacency matrix of a graph (Example 11.3.4)
25
Summary
• Definitions: vertex, edge, loop, parallel edges, complete graph and bipartite
• Paths & circuits: Euler and Hamiltonian circuits. Finding Euler circuit is easy but not so for Hamiltonian
• Matrix representation of graphs: adjacency matrix
26
THE END
THANK YOU