Docsity

Graph Theory - Discrete Math - Lecture Slides, Slides of Discrete Mathematics

Partial preview of the text

Download Graph Theory - Discrete Math - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

Discrete Maths

  • Objective
    • introduce graph theory (e.g. Euler and

Hamiltonian cycles), and discuss some

graph algorithms (e.g. Dijkstra’s shortest

path).

5. Graph Theory

Overview

1. Introduction

2. Cycles

3. Hamiltonian Cycles

4. Algorithms for Finding Cycles

5. Similarity Graphs

6. Implementing Graphs

continued

1. Introduction

Muddy Gap

Casper

Douglas

Gillettte Buffalo

Sheridan

Greybull

Worland

Shoshoni

Lander

Part of Wyoming’s (a USA State)

Road System

Problem

• The Wyoming Road Inspector lives in Greybull,

and must check every road.

• He must check the roads as quickly as possible

  • by travelling each road only once
  • starting from Greybull and returning there

• Is this travel plan possible?

  • Dots = vertices/nodes (singular: vertex)
  • Lines = edges/arcs
  • An undirected graph is one where the edges

have no direction (no arrows) on them.

Equivalent Graph

Cas

Sho

Lan

Mud

Wor

Gre

She

Buf

Gil

Dou

e

e

e12 e4 e

e

e

e

e e

e

e

e

Answer: No

• Consider Worland (Wor): the inspector

must use every edge connected to Wor

only once.

Sho

Wor

Gre

Buf

e

e

e

continued

  • But to travel through Wor requires 2 edges

(one in, one out).

  • So there is no way to use the third edge to

visit Wor without using one of the other edges

again.

1 .2. A Directed Graph

  • A directed graph = vertices/nodes and arcs.

    • v • An arc = a directed edge (one with an arrow).
      • v - v - v - v - v
  • e - e - e - e - e4 e - e

A Calling Graph

• A Calling Graph for a small program:

main

printList

mergeSort

split merge

makeList

4 examples of

direct recursion

  • Parallel Edges e1, e2 = (v1, v2)

A loop e3 = (v2, v2)

Isolated (or unconnected) vertex: v

  • A graph with no loops and no parallel edges is

a simple graph.

  • A graph with no isolated verticies is a

connected graph.

1 .4. Path Length

• The length of a path = the number of edges

that it uses.

• If edges/arcs are labeled with numbers then

we can sum the values along a path to get a

“distance”.

A Weighted Graph Version

• Add edge numbers (weights) to indicate the

movement time between any two holes.

12

9

4

4

3

5

6

8

6

a

d

e

c

b

2

Simplified Problem

• Assume that the drilling must start at vertex

‘a’ and end at vertex ‘e’.

• What is the path with the shortest length

between ‘a’ and ‘e’?

  • length = sum of weights on the path’s edges