26
Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

Discrete StructuresChapter 7B

GraphsNurul Amelina Nasharuddin

Multimedia Department

Page 2: Discrete Structures Chapter 7B Graphs Nurul 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

Page 3: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 4: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 5: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 6: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

6

Example - Path

• Path

v

• Simple path

w

Page 7: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 8: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

8

Example - Circuit

• Circuit

• Simple circuit

Page 9: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 10: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 11: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

11

Example - Connectedness

Page 12: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 13: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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.

Page 14: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 15: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 16: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 17: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 18: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

18

Hamiltonian Circuit

• Finding Hamiltonian circuits

Page 19: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

19

Traveling Salesman Problem

http://en.wikipedia.org/wiki/Traveling_Salesman_Problem

Page 20: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 21: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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.

Page 22: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

22

Examples

• Adjacency matrix of a graph (Example 11.3.2)

• Obtaining a directed graph from a matrix (Example 11.3.3)

Page 23: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 24: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

24

Examples

• Finding the adjacency matrix of a graph (Example 11.3.4)

Page 25: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

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

Page 26: Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department

26

THE END

THANK YOU