280 likes | 487 Views
DM OR. 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 .
E N D
DMOR Networks
Graphs: Koenigsberg bridges Leonard Euler problem (1736)
Eachsuch walk has to enter and leaveanygivennode. Thedegree of anynodehas to be even.
Euleriancycle 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 • Variablexij= 1, ifthesalesmanpassesfromitoj, 0 otherwise • Goingfrom one city to the same city isforbidden • Isthisall ???
TSP • Isthisall? • Let’ssayoursolutionwith 5 citiesisx12=x23=x31=x45=x54=1 • Itsatisfiesalltheconstraints. But itinvolvessubtours (cyclesinvolvingfewerthanallcities) • We need to introduceadditionalconstraints
Subtourelimination • For twocities • For threecities • For fourcities • Etc. • In practicalimplementationtoo many constraints: with30 citiestherewould be 870 constraintseliminatingonlysubtours of length 2
Subtoureleimination– secondapproach • Introducenonnegativevariablesui: • Subtoursareeliminated • How many suchconstraints? • (N-1)2-N, i.e. with30 citiestherewould be 812constraints.
Game • http://www.tsp.gatech.edu/games/index.html
Introduction to networks • Twomainelements: • arcs/edges • nodes • A graphis a structureconsisting of nodes and arcsbewteennodes • A directedgraph(a digraph)is a graphinwhicharcshave a givendirection • A networkis a graph(ordigraph), inwhicharcshave a flowassigned to it • Simple examples:
Introduction to networks • Chainis a sequence of arcsconnectingtwonodesiandj, e.g.figure on theright: ABCE, ADCE • Pathis a sequence of directedarcsconnectingtwonodes , e.g. figure on therightABDE, but not ABCE • Cycle is a chain, whichconnects a nodewiththe same nodewithoutanyrepetition (retracing) e.g. figure on therightABCEDA, but not ABCDECBA • Connectedgraph/network hasonly one part Graph Directedgraph
Introduction to networks • Tree – a connectedgraphwhichdoes not havecycles. • Spanningtreeis a treechosenamongarcsinthegraph so thatallnodesinthetreewereconnected Twospanningtrees Twotrees • Flowcapacity – upper (sometimesalsolower) limit for theflowat a givenarcinthenetwork, e.g. maximalnumber of cars thatcan pass per minuteat a givenroad • Sourceis a nodewhichintroduces a flowintothenetwork • Sinkis a nodewhichtakestheflow out of thenetwork
The shortest route problem • Formulation:For a givengraphinwhicheveryarcisassignedwith a distancebewteenthetwonodesitconnects, whatistheshortestpathbetweennode i and j. • Example: Whatistheshortestroutebewteen A and H? Enumeration – impractical Dijkstraalgorithm
Dijkstraalgorithm http://optlab-server.sce.carleton.ca/POAnimations2007/DijkstrasAlgo.html
Minimum spanning tree • Formulation:For a givengraph, inwhicheveryarcisassignedwith a distancebetweenthetwonodesitconnects, find a spanningtreethathasminimaltotallength. • Example: Findminimallength for a wirethatconnectsalltheofficesinthebuildingwhenalltheavailablewirepathsaregiven. • Algorithm: http://optlab-server.sce.carleton.ca/POAnimations2007/MinSpanTree.html An example of the so calledgreedy algorithm –itdoeswhat’sbestin a given step not lookingattheotherstages of the problem (usuallyineffective – hereitiseffective!) One can do a maximalspanningtreethe same way
Maximum flow and the minimum cut • Formulation:Whatisthemaximalflowbetweentwogivennodesin a graph? Eachnodeisassignedwith a maximalflow. • Example: Find a maximalflow of cars from an underground parking lot downtown to themotorwayentrance. • Eacharcisassignedwith a maximalsimultaneousflowbetweenthetwonodesitconnects • Maximalflowmaydifferdepending on theflowdirection (e.g. one-waystreets) Examplesolution: 4 cars/m on route A-D-E-G 3 cars/m ojnroute A-B-E-G 4 cars/m on route A-C-F-G Total flowbetween A and G is11 cars/m Isthisoptimal???
Maximum flow and the minimum cut • Algorithm: Ford and Fulkerson (Canadian Journal of Mathematics 1956) http://optlab-server.sce.carleton.ca/POAnimations2007/MaxFlow.html
Maximumflow/minimum cut • In Ford Fulkersonalgorithm, why do we need to addflowintheoppositedirection? • Accountingconventionthatkeepstrack of theflowthat, ifnecessary, can be reversed.
Maximumflow/minimum cut • Maximumflowiscloselyrelated to minimum cut: • A cutin a graphis a set of directedarcswhichcontainsatleast one arcineverypossiblepathfromthesource to thesink. If we removearcsfrom a givencut, theflowfromthesource to thesink will no longer be possible. • Cutvalueisthe sum of allflowcapacities (directionfromthesource to thesink) for eacharcin a cut. • Possiblecutswithcutvaluesindicated on them