Repeated vertex?

Discrete Structures
Chapter 7B
Graphs
Nurul Amelina Nasharuddin
Multimedia Department
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
2
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
3
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
4
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
5
Example - Path
• Path
v
w
• Simple path
6
Circuit
• Circuit – a closed walk without repeated edge
v0e1v1e2…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
7
Example - Circuit
• Circuit
• Simple circuit
8
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
9
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
10
Example - Connectedness
11
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
12
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.
13
Theorem: Euler Circuits
• 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.
• If every vertex of nonempty graph has even degree
and if graph is connected, then the graph has an
Euler circuit
14
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
15
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
16
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
17
Hamiltonian Circuit
• Finding Hamiltonian circuits
18
Traveling Salesman Problem

http://en.wikipedia.org/wiki/Traveling_Salesman_Problem
19
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
20
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.
21
Examples
• Adjacency matrix of a graph (Example 11.3.2)
• Obtaining a directed graph from a matrix (Example
11.3.3)
22
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
23
Examples
• Finding the adjacency matrix of a graph (Example
11.3.4)
24
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
25
THE END
THANK YOU
26