problem solving with networks

25
Problem Solving with Networks 18/08/2012 Jamie Sneddon [email protected]

Upload: ludlow

Post on 24-Feb-2016

49 views

Category:

Documents


0 download

DESCRIPTION

Problem Solving with Networks. 18 /08/2012 Jamie Sneddon [email protected]. Networks, graphs. A graph is collection of points with lines between them A network is a graph with positive numbers assigned to its edges as weights. Distances in miles between some US cities. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Problem Solving with Networks

Problem Solving with Networks18/08/2012

Jamie [email protected]

Page 2: Problem Solving with Networks

Networks, graphs A graph is collection of points with

lines between them

A network is a graph with positive numbers assigned to its edges as weights

point linevertex (vertices) edge

node arc

Page 3: Problem Solving with Networks

Distances in miles between some US cities

Page 4: Problem Solving with Networks

Detroit MI

Columbus OH

Washington DC

PittsburghPA

Philadelphia PA

New YorkNY

Rochester NYBuffalo NY

Cleveland OH

ToledoOH

Scranton PA

Harrisburg PA

Distances in miles between some US cities

Page 5: Problem Solving with Networks

Detroit MI

Columbus OH

Washington DC

PittsburghPA

Philadelphia PA

New YorkNY

Rochester NYBuffalo NY

Cleveland OH

ToledoOH

Scranton PA

Harrisburg PA

Distances in miles between NE state US cities

Page 6: Problem Solving with Networks

Detroit MI

Columbus OH

Washington DC

PittsburghPA

Philadelphia PA

New YorkNY

Rochester NYBuffalo NY

Cleveland OH

ToledoOH

Scranton PA

Harrisburg PA

Distances in miles between NE state US cities

Page 7: Problem Solving with Networks

61

144

117

25573

190

134142

185

246141

204

112

217

121

95125

121

Distances in miles between NE state US cities

107

Page 8: Problem Solving with Networks

Detroit MI

Columbus OH

Washington DC

PittsburghPA

Philadelphia PA

New YorkNY

Rochester NYBuffalo NY

Cleveland OH

ToledoOH

Scranton PA

61

144

117

25573

190

134142

185

246141

Harrisburg PA204

112

217

121

95125

121

Distances in miles between NE state US cities

107

Page 9: Problem Solving with Networks

61

144

117

25573

190

134142

185

246141

204

112

217

121

95125

121

Distances in miles between NE state US cities

107

T

DB R

H

S

N

Ph

W

PiCl

Co

Page 10: Problem Solving with Networks

61

144

117

25573

190

134142

185

246141

204

112

217

121

95125

121

Spanning Tree with edge deletion

107

T

DB R

H

S

N

Ph

W

PiCl

Co

Page 11: Problem Solving with Networks

61

144

117

25573

190

134142

185

246141

204

112

217

121

95125

121

Spanning Tree with edge inclusion (1)

107

T

DB R

H

S

N

Ph

W

PiCl

Co

Page 12: Problem Solving with Networks

61

144

117

25573

190

134142

185

246141

204

112

217

121

95125

121

Spanning Tree with edge inclusion (2)

107

T

DB R

H

S

N

Ph

W

PiCl

Co

Total weight = 1356 miles

Page 13: Problem Solving with Networks

Problems in networks (0) Are all the nodes connected? (1) What is the lowest weight

(smallest) tree which connects all the nodes?

(2) What is the shortest distance from A to B?

(3) Can every edge be used exactly once?

(4) Can every node be visited exactly once?

(5) What is the shortest way to visit every node exactly once?

Page 14: Problem Solving with Networks

(0) Connectedness It’s usually easy to tell if a real-world

network is connected or not. Starting at an arbitrary node, if we list that node’s neighbours, then their neighbours, then theirs, we might eventually visit all the nodes.

[ACTIVITY] If we don’t, it’s not c0nnected.

Page 15: Problem Solving with Networks

(1) Spanning Tree A minimum weight spanning tree is a

sub-graph without cycles which connects all the nodes.

A tree with n nodes has n-1 edges.

Sometimes it’s easier to add edges, sometimes remove them.

Page 16: Problem Solving with Networks

(2) Shortest Path Starting at a particular node A, what

is the shortest path to another vertex B (or to all other vertices).

[ACTIVITY 2]

Page 17: Problem Solving with Networks

(3) Traversability Is it possible to start at a node A and

follow a route through the network which uses every edge exactly once?

If so, does the path return to A, or end elsewhere?

Easily characterised with node parity (even/odd)

Page 18: Problem Solving with Networks

(4) Visiting nodes Is it possible to start at a node A and

follow a route through the network visits every NODE exactly once?

If so, does the path return to A, or end elsewhere?

Called Hamiltonian: no characterisation, and hard to find

Page 19: Problem Solving with Networks

(5) Travelling Salesman What is the shortest Hamiltonian

cycle/path? This is harder still!

TSP (Travelling Salesman Problem) is the definitive “hard” problem of computational mathematics

Page 20: Problem Solving with Networks

Real World / Mathematical World

Networks don’t always model the real world perfectly – what could go wrong?

One way edges Different weight directions on edges Variable data (time of day, day of

week) Roads branching outside towns

Page 21: Problem Solving with Networks

Questions beyond the procedural

Why did you use this algorithm? Compare two algorithms

edge inclusion vs edge deletion How could the network be changed

to give (or remove) a property What does this mean in relation to

the given problem

Page 22: Problem Solving with Networks

How doesadding / deletingnodes / edgeschange the

shortest paths / spanning trees?

Page 23: Problem Solving with Networks

Where to add connections? Where in the network should edges

be added/removed so that it is traversable?

Page 24: Problem Solving with Networks

Optional nodes What if we want to allow the

possibility of a node outside a town?

Construct two spanning trees: with/without

4

5

5

32.5

2.5

2

1

5

3

Page 25: Problem Solving with Networks

For more: Wikipedia! Prim’s Algorithm (connected sub-

tree) Kruskal’s Algorithm (partial trees) Reverse-Delete Algorithm (remove

edges) Dijkstra’s Algorithm Euler Path – Fleury’s Algorithm

Jamie Sneddon [email protected]