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

## Presentation on theme: "DMOR Networks. Graphs: Koenigsberg bridges Leonard Euler problem (1736)"— Presentation transcript:

DMOR Networks

Graphs: Koenigsberg bridges Leonard Euler problem (1736)

Nodes

Edges

Is there a walk which uses each edge exactly once?

Build two more bridges.

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

Eulerian cycle Hamiltonian cycle Travelling salesman problem

TSP - cycle Duration: 2 d 7 h 2 m Length: 3615 km

TSP - trail Duration: 2 d 4 h 37 m Length: 3436 km

TSP – a real walk Duration: 29 d 11 h 21 m Length: 3485 km

Travelling salesman problem TSP Mathematically Variable x ij = 1, if the salesman passes from i to j, 0 otherwise Going from one city to the same city is forbidden Is this all ???

TSP Is this all? Let’s say our solution with 5 cities is x 12 =x 23 =x 31 =x 45 =x 54 =1 It satisfies all the constraints. But it involves subtours (cycles involving fewer than all cities) We need to introduce additional constraints

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

Subtour eleimination – second approach Introduce nonnegative variables u i : Subtours are eliminated How many such constraints? (N-1) 2 -N, i.e. with 30 cities there would be 812 constraints.

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

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: NodesArcsFlow CitiesHighwaysCars HubsWire Transmitted packets Pipelines jointsPipesWater

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 GraphDirected graph

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 trees Two 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

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

http://optlab- server.sce.carleton.ca/PO Animations2007/Dijkstras Algo.html

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/POAnimations 2007/MinSpanTree.html

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???

Maximum flow and the minimum cut Algorithm: Ford and Fulkerson (Canadian Journal of Mathematics 1956) http://optlab- server.sce.carleton.ca/POAnimations2007/MaxFlow.html

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

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