Routing algorithms, all distinct routes, ksp, max-flow, and network flow LPs W. D. Grover TRLabs & University of Alberta © Wayne D. Grover 2002, 2003 E E Module 5
E E Module 5 © Wayne D. Grover 2002, (for non-negative edge weights only) Key concepts: “labelling”, “scanning” Label = {distance, predecessor}. Labels are initially “temporary” later “permanent”. “Scanning” is the process of looking out from a given node to all adjacent nodes that are not permanently labelled and is shorter. Example: find shortest A-H route if the edge weights represent distance Dijkstra’s “shortest path” algorithm
E E Module 5 © Wayne D. Grover 2002, Start: [P] a vector of permanently labelled nodes, [D] a vector of distances - [P] <- [A] - All other nodes are unlabelled - [D] <- all infinite - source is already perm. labelled Step 1: “Scan” from node A: nodes B, C, D get temp labels node B gets perm label: [P] = [A, B] [D] = [-, 2] 2, A 6, A 7, A Dijkstra’s “shortest path” algorithm (2)
E E Module 5 © Wayne D. Grover 2002, Step 2: “Scan” from node B: scan goes only to other nodes not yet perm labelled node E gets {9, from B} node F gets {17, from B} node C gets its label updated: {5, from B} node C is lowest global distance so it gets the permanent label this time [P] = [A, B, C] [D] = [-, 2, 5] 2, A 6, A 7, A 2+ 7 = 9, from B 17, B 5, B Dijkstra’s “shortest path” algorithm (3)
E E Module 5 © Wayne D. Grover 2002, Step 3: “Scan” from node C: node G gets {8, from C} node D keeps {7, from A} node D is lowest global distance amongst temp labels so it gets the permanent label this time [P] = [A, B, C, D] [D] = [-, 2, 5, 7] 2, A 7, A 9, B 17, B 5, B 8, C Dijkstra’s “shortest path” algorithm (4)
E E Module 5 © Wayne D. Grover 2002, Step 4: “Scan” from node D: node F gets updated label {16, from D} node G keeps {8, from C} node G is lowest global distance amongst temp labels so it gets the permanent label this time [P] = [A, B, C, D, G] [D] = [-, 2, 5, 7, 8] 2, A 7, A 9, B 16, D 5, B 8, C Dijkstra’s “shortest path” algorithm (5)
E E Module 5 © Wayne D. Grover 2002, Step 5: “Scan” from node G: node H gets label {14, from G} Since H is also target tempting to stop, but not yet. Node E (not just scanned) gets next perm. Label. [P] = [A, B, C, D, G, E] [D] = [-, 2, 5, 7, 8, 9] 2, A 7, A 9, B 16, D 5, B 8, C 14, G Dijkstra’s “shortest path” algorithm (6)
E E Module 5 © Wayne D. Grover 2002, Step 6: “Scan” from node E: node H keeps label {14, from G} node H label permanent now [P] = [A, B, C, D, G, E, H] [D] = [-, 2, 5, 7, 8, 9, 14] hence: A-H shortest route is of distance 14, via: H -> G -> C -> B -> A 2, A 7, A 9, B 16, D 5, B 8, C 14, G If we continue, however, we will get the complete tree of shortest routes from A to all other nodes... Dijkstra’s “shortest path” algorithm (7)
E E Module 5 © Wayne D. Grover 2002, Step 7: only node F is not permanently labelled: scan from H Node F label {16, from D} is made permanent [P] = [A, B, C, D, G, E, H, F] [D] = [-, 2, 5, 7, 8, 9, 14, 16] 2, A 7, A 9, B 16, D 5, B 8, C 14, G Finally all nodes have permanent labels... the complete tree of shortest routes from A to all other nodes has been found... Dijkstra’s “shortest path” algorithm (8)
E E Module 5 © Wayne D. Grover 2002, Recap: start at source (first perm label): scan from latest perm label, update temp labels find lowest temp label make perm loop till:target is perm. label (path only) all nodes perm (whole tree) Things to remember: (1) Only stop when target node is permanently labelled. (2) The next node to scan from may not be one just visited in the last scan. At the end, the [D], [P] vectors (plus labels) encode the shortest path tree: Dijkstra’s “shortest path” algorithm (9)
E E Module 5 © Wayne D. Grover 2002, “k-shortest paths (ksp)” One model of “mesh” restoration re-routing is ksp: In this context it means: –the set of all paths on the shortest route, –plus all paths feasible on the second-shortest route, not using any links of the first set, –plus all paths feasible on the third-shortest route, not using any links of the first or second set, –etc. until restoration is satisfied or no more paths are feasible. No route or path is looping. The sum of all paths on routes that cross any one span is consistent with the spare capacity available on that span.
E E Module 5 © Wayne D. Grover 2002, On the network we just used for Dijkstras algorithm.... Note (!) : We now interpret the same edge weights as capacities (just for an example) Using hop count as distance, A C G H is one shortest (3 hop) routes It supports min (6, 3, 6) = 3 paths This exhausts (C-G) and reduces capacity on (A C) (G H) to 3 “k-shortest paths (ksp)” - example
E E Module 5 © Wayne D. Grover 2002, Next 3 hop route is A D F H It supports min (7, 9, 9) = 7 paths It exhausts span (A-D) and reduces capacity on spans (D F) and (F H) to 2.. The updated graph and next route is “k-shortest paths (ksp)” - example (2)
E E Module 5 © Wayne D. Grover 2002, Next shortest route is A B E H It supports min (2, 7, 7) = 2 paths It exhausts span (A-B) and reduces capacity on spans (B E) and (E H) to The updated graph and next route is... “k-shortest paths (ksp)” - example (3)
E E Module 5 © Wayne D. Grover 2002, Next shortest route is A C D G H It supports 3 paths It exhausts spans (A-C) (G-H) and.. Disconnects the graph between A-H “k-shortest paths (ksp)” - example (4) The updated graph and next route is...
E E Module 5 © Wayne D. Grover 2002, paths ______ 15 The resulting “ksp” path-set is... route A-C-G-H A-D-F-H A-B-E-H A-C-D-G-H Total: “k-shortest paths (ksp)” - example (5)
E E Module 5 © Wayne D. Grover 2002, paths _____ 15 Note that when the distances are integer (hop counts here), the ksp outcome is not unique and can depend on order of choosing routes route A-D-G-H A-C-G-H A-D-F-H A-C-B-F-H A-C-D-F-H A-B-F-H Total: Another valid “ksp” solution “k-shortest paths (ksp)” - example (6)
E E Module 5 © Wayne D. Grover 2002, Note that the last two path-sets differ greatly in detailed construction, but the number of paths is the same - Q. what governs this ? Note that both prior solutions both disconnect the graph by exhausting all capacity on spans (A B) (A C) (A D).... In fact both ksp solutions are equivalent to the maximum-flow between A-H for this graph. Moreover, the max-flow, is set (to 15) by the min-cut shown “k-shortest paths (ksp)” - example (7)
E E Module 5 © Wayne D. Grover 2002, At termination, network is disconnected in forward flows, across min cut here “Reverse direction arc of same capacity as used, is like reserving an option to reverse this decision later. Maximum flow algorithm
E E Module 5 © Wayne D. Grover 2002, A cut of a graph G(V,E) is a partitioning of the nodes of the graph into two disjoint sets A cutset is the set of edges The capacity of a cut is the sum of the weights on the edges of the cutset. The min-cut max-flow theorem is that : or... More intuitively: “regardless of the routing details, the maximum flow between two nodes is set by the minimum capacity of any cut of the between those two nodes” or…“some combination of spans in parallel will always act as the bottleneck” Min-cut max-flow theorem
E E Module 5 © Wayne D. Grover 2002, A B E C D F the “min-cut” = 12 Hence --> no routing solution can provide more than 12 units of flow between A -F (i.e., this is the “max-flow”) Illustration of the “max-flow = min-cut” concept
E E Module 5 © Wayne D. Grover 2002, A. The vast majority (> 99.9%) of the time they are identical in transport network graphs having 2 < d < ~5 (Dunn, Grover, IEEE JSAC 1994) Where they differ it is always due to an instance of the “trap topology”: Q. When are ksp and max-flow not equivalent?
E E Module 5 © Wayne D. Grover 2002, Example of how the max flow algorithm avoids the trap
E E Module 5 © Wayne D. Grover 2002, The set (or subsets of) of “all distinct routes” is often required in mesh network capacity design formulations. - very different from set of disjoint or ksp routes: |route-set| = O(2 dH ) intuitive illustration : “All distinct routes”
E E Module 5 © Wayne D. Grover 2002, Example of first phase of DFS to find all distinct routes from A - H subject to hop-limit of 3 Generating “all distinct routes” by depth-first search
E E Module 5 © Wayne D. Grover 2002, Example: LP to find max flow between nodes Edge capacities: Define directional flow variables: source sink “trans-shipment nodes” 2 Network flow LP formulations x x 12 x 13 x 32 x 23 x 45 x 24 x 35
E E Module 5 © Wayne D. Grover 2002, To maximize (1 5) flow :/* using lp_solve syntax */ max: x12 + x13 ;/* (or x35 + x45) */ subject to constraints: c1: x12 + x13 = x45 + x35 ;/* source = sink */ c2: x12 + x32 - x23 + x42 - x24 = 0 ;/* node 2 trans-shipment*/ c3: x13 + x23 - x32 - x35 = 0 ;/* node 3 trans-shipment*/ c4: x24 - x45 - x42 = 0 ;/* node 4 trans-shipment*/ Network flow LP formulations (2) “transportation problem” or “arc-flow” approach x x 12 x 13 x 32 x 23 x 45 x 24 x 35
E E Module 5 © Wayne D. Grover 2002, Continued.... Also subject to (span capacity constraints): x12 < 20 ; x13 < 8 ; x24 < 10 ; x42 < 10 ; x23 < 2 ; x32 < 2 ; x35 < 20 ; x45 < 5 ; Network flow LP formulations (2) “transportation problem” or “arc-flow” approach
E E Module 5 © Wayne D. Grover 2002, Symbolically.... s.t. Where: E = set of edges that exist N = set of nodes s ij = spare capacity on edge ij (= s ji ) Network flow LP formulations (3) “transportation problem” or “arc-flow” approach
E E Module 5 © Wayne D. Grover 2002, Symbolically.... s.t. Where: E = set of edges that exist (indexed by k) P 15 = set of “eligible” distinct routes between nodes 1 and 5 (source-sink) s k = spare capacity on edge k if the i th distinct route crosses span k. Zero otherwise Network flow LP formulations (4) Alternate approach: “flow assignment to routes” or “arc-path” approach
E E Module 5 © Wayne D. Grover 2002, Identify all distinct routes between source- sink (set P 15 ).... Route associated flow variable f f2 Route associated flow variable f f f1 f2 f3 f4 Network flow LP formulations (5) “flow assignment to routes” or “arc-path” approach - example
E E Module 5 © Wayne D. Grover 2002, To maximize (1 -> 5) flow : max: f1 + f2 + f3 + f4 ; subject to constraints: c1: f1 + f2 <= 20 ;/*span 12 capacity */ c2: f4 + f3 <= 8 ;/* span 13 capacity */ c3: f4 + f2 <= 2 ;/* span 23 (discuss this ) */ c4: f1 + f4 <= 10 ;/* span 24 */ f1 f2 f3 f Network flow LP formulations (6) “flow assignment to routes” or “arc-path” approach - example (2)
E E Module 5 © Wayne D. Grover 2002, Class : What are the remaining constraints ? : - for span ?: - for span ? f2 f3 f c5: f3 + f2 <= 20; /*span 35 capacity */ c6: f4 + f1 <= 5; /*span 45 capacity */ f1 (note this makes prior constraint f4 + f1<=10 redundant ) Network flow LP formulations (6) “flow assignment to routes” or “arc-path” approach - example (2)
E E Module 5 © Wayne D. Grover 2002, Note that the “indicator” parameters do not appear explicitly in the executable model. Really they just represent our knowledge of the topology and the routes being considered. Implicitly above, we only wrote the flow variables that had non-zero coefficients. Examples: Hence f1 is in the first constraint Hence f3 is in the fifth constraint, etc. Network flow LP formulations (7) “flow assignment to routes” or “arc-path” approach - example (3)