dmor networks. graphs: koenigsberg bridges leonard euler problem (1736)

28
DMOR Networks

Upload: daniela-mcdaniel

Post on 19-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

DMOR

Networks

Page 2: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Graphs: Koenigsberg bridges

Leonard Euler problem (1736)

Page 3: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Nodes

Page 4: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Edges

Page 5: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Is there a walk which uses each edge exactly once?

Page 6: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Build two more bridges.

Page 7: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Each such walk has to enter and leave any given node. The degree of any node has to be even.

Page 8: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Eulerian cycle

Hamiltonian cycle

Travelling salesman problem

Page 9: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

TSP - cycle

Duration: 2 d 7 h 2 m Length: 3615 km

Page 10: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

TSP - trail

Duration: 2 d 4 h 37 mLength: 3436 km

Page 11: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

TSP – a real walk

Duration: 29 d 11 h 21 m Length: 3485 km

Page 12: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)
Page 13: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Travelling salesman problem TSP• Mathematically

• Variable xij = 1, if the salesman passes from i to j, 0 otherwise• Going from one city to the same city is forbidden• Is this all ???

min𝑥𝑖𝑗 𝑑𝑖𝑗𝑥𝑖𝑗𝑗𝑖≠𝑗𝑖 p.w. 𝑥𝑖𝑗𝑗𝑖≠𝑗

= 1, for all 𝑖 𝑥𝑖𝑗𝑖𝑖≠𝑗

= 1, for all 𝑗 𝑥𝑖𝑗 = 0 or 1, for all 𝑖 and 𝑗,where 𝑖 ≠ 𝑗

Page 14: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

TSP

• Is this all?• Let’s say our solution with 5 cities is

x12=x23=x31=x45=x54=1• It satisfies all the constraints. But it involves

subtours (cycles involving fewer than all cities)• We need to introduce additional constraints

Page 15: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Subtour elimination• For two cities

• For three cities

• For four cities

• Etc.• In practical implementation too many constraints: with 30 cities there

would be 870 constraints eliminating only subtours of length 2

Page 16: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Subtour eleimination – second approach

• Introduce nonnegative variables ui:

• Subtours are eliminated

• How many such constraints? • (N-1)2-N, i.e. with 30 cities there would be 812 constraints.

Page 17: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)
Page 18: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Game

• http://www.tsp.gatech.edu/games/index.html

Page 19: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Introduction to networks• Two main elements:

– arcs/edges – nodes

• A graph is a structure consisting of nodes and arcs bewteen nodes• A directed graph (a digraph) is a graph in which arcs have a given

direction • A network is a graph (or digraph), in which arcs have a flow assigned to it• Simple examples:

Nodes Arcs Flow

Cities Highways Cars

Hubs Wire Transmitted packets

Pipelines joints Pipes Water

Page 20: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Introduction to networks• Chain is a sequence of arcs connecting two nodes i and j, e.g. figure on

the right: ABCE, ADCE• Path is a sequence of directed arcs connecting two nodes , e.g. figure

on the right ABDE, but not ABCE• Cycle is a chain, which connects a node with the same node without

any repetition (retracing) e.g. figure on the right ABCEDA, but not ABCDECBA

• Connected graph/network has only one part

Graph Directed graph

Page 21: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Introduction to networks• Tree – a connected graph which does not have cycles.• Spanning tree is a tree chosen among arcs in the graph

so that all nodes in the tree were connected

Two spanning treesTwo trees

• Flow capacity – upper (sometimes also lower) limit for the flow at a given arc in the network, e.g. maximal number of cars that can pass per minute at a given road

• Source is a node which introduces a flow into the network • Sink is a node which takes the flow out of the network

Page 22: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

The shortest route problem

• Formulation: For a given graph in which every arc is assigned with a distance bewteen the two nodes it connects, what is the shortest path between node i and j.

• Example: What is the shortest route bewteen A and H?

Enumeration – impractical

Dijkstra algorithm

Page 23: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Dijkstra algorithm

http://optlab-server.sce.carleton.ca/POAnimations2007/DijkstrasAlgo.html

Page 24: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Minimum spanning tree

• Formulation: For a given graph, in which every arc is assigned with a distance between the two nodes it connects, find a spanning tree that has minimal total length.

• Example: Find minimal length for a wire that connects all the offices in the building when all the available wire paths are given.

• Algorithm:

An example of the so called greedy algorithm – it does what’s best in a given step not looking at the other stages of the problem (usually ineffective – here it is effective!)

One can do a maximal spanning tree the same way

http://optlab-server.sce.carleton.ca/POAnimations2007/MinSpanTree.html

Page 25: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Maximum flow and the minimum cut

• Formulation: What is the maximal flow between two given nodes in a graph? Each node is assigned with a maximal flow.

• Example: Find a maximal flow of cars from an underground parking lot downtown to the motorway entrance.

• Each arc is assigned with a maximal simultaneous flow between the two nodes it connects – Maximal flow may differ depending on the flow direction (e.g. one-way streets)

Example solution:4 cars/m on route A-D-E-G

3 cars/m ojn route A-B-E-G

4 cars/m on route A-C-F-G

Total flow between A and G is 11 cars/m

Is this optimal???

Page 26: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Maximum flow and the minimum cut

• Algorithm: Ford and Fulkerson (Canadian Journal of Mathematics 1956)

http://optlab-server.sce.carleton.ca/POAnimations2007/MaxFlow.html

Page 27: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

• In Ford Fulkerson algorithm, why do we need to add flow in the opposite direction?– Accounting convention that keeps track of the flow that, if necessary, can be

reversed.

Maximum flow/minimum cut

Page 28: DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)

• Maximum flow is closely related to minimum cut:– A cut in a graph is a set of directed arcs which contains at least one arc in every

possible path from the source to the sink. If we remove arcs from a given cut, the flow from the source to the sink will no longer be possible.

– Cut value is the sum of all flow capacities (direction from the source to the sink) for each arc in a cut.

• Possible cuts with cut values indicated on them

Maximum flow/minimum cut