De presentatie wordt gedownload. Even geduld aub

De presentatie wordt gedownload. Even geduld aub

Netwerk Algorithms: Shortest paths1 Shortest paths II Network Algorithms 2004.

Verwante presentaties


Presentatie over: "Netwerk Algorithms: Shortest paths1 Shortest paths II Network Algorithms 2004."— Transcript van de presentatie:

1 Netwerk Algorithms: Shortest paths1 Shortest paths II Network Algorithms 2004

2 Netwerk Algorithms: Shortest paths2 Gabow’s algorithm Gabow (G, s, w) –Set for all e: w’(e) =  w(e) / d  –With Gabow(G, s, w’), compute for all v: d w’ (s,v) –Set for all e: W(e) = w(u,v) + d * d w’ (s,u) – d * d w’ (s,v). –Compute with Dijkstra with doubly-linked lists datastructure for all v: d W (s,v) –Output for all v: d(s,v) = d W (s,v) – d * d w’ (s,v)

3 Netwerk Algorithms: Shortest paths3 All pairs Dynamic programming: O(n 3 ) (Floyd, 1962) Johnson: improvement for sparse graphs with reweighting technique: –O(n 2 log n + nm) time. –Works if no negative cycles –Observation: if all weights are non-negative we can run Dijkstra with each vertex as starting vertex: that gives O(n 2 log n + nm) time. –What if we have negative lengths: reweighting…

4 Netwerk Algorithms: Shortest paths4 Reweighting Let h: V  R be any function to the reals. Write w h (u,v) = w(u,v) + h(u) – h(v). Lemmas: –Let P be a path from x to y. Then w h (P) = w(P) + h(x) – h(y). –P is a shortest path from x to y with lengths w, if and only if it is so with lengths w h. –G has a negative-length circuit with lengths w, if and only if it has a negative-length circuit with lengths w h. Potentials

5 Netwerk Algorithms: Shortest paths5 What height function h is good? Look for height function h with –w h (u,v)  0, for all edges (u,v). If so, we can: –Compute w h (u,v) for all edges. –Run Dijkstra but now with w h (u,v). Special method to make h with a SSSP problem, and Bellman-Ford.

6 Netwerk Algorithms: Shortest paths6 G s 0 0 0 0

7 7 Choosing h Set h(v) = d(s,v) (in new graph) Solving SSSP problem with negative edge lengths; use Bellman-Ford. If negative cycle detected: stop. Note: for all edges (u,v): w h (u,v) = w(u,v) + h(u) – h(v) = w(u,v) + d(s,u) – d(s,v)  0

8 Netwerk Algorithms: Shortest paths8 Johnson’s algorithm Build graph G’ (as shown) Compute with Bellman-Ford d(s,v) for all v Set w h (u,v) = w(u,v) – d(s,u) + d(s,v) for all edges (u,v). For all u do: –Use Dijkstra’s algorithm to compute d h (u,v) for all v. –Set d(u,v) = d h (u,v) + h(v) – h(u). O(n 2 log n + nm) time

9 Netwerk Algorithms: Shortest paths9 Conclusions Several algorithms for shortest paths –Variants of the problem –Detection of negative cycles –Scaling technique –Reweighting technique Applications

10 Netwerk Algorithms: Shortest paths10 Bottleneck shortest path Gegeven: gerichte graaf G, gewicht w(e) voor elke pijl, knopen s en t Gevraagd: zoek een pad van s naar t zodat het maximum gewicht van een pijl op het pad zo klein mogelijk is. –Of, omgekeerd: het minimum gewicht zo groot mogelijk: maximum capacity path

11 Netwerk Algorithms: Shortest paths11 Algoritmen Op gerichte grafen: O((m+n) log m), –Of: O((m+n) log L) met L maximum absolute waarde van gewicht –Binary search en DFS Op ongerichte grafen: O(m+n) met divide and conquer strategie

12 Netwerk Algorithms: Shortest paths12 Bottleneck shortest paths op ongerichte grafen Vind de mediaan van de gewichten van alle kanten, zeg r. Kijk naar graaf G r gevormd door kanten met gewichten hooguit r. Als s en t in zelfde samenhangscomponent in G r zitten: bottleneck is hooguit r; we laten alle kanten met gewicht meer dan r weg, en herhalen (recursie.) Als s en t in verschillende samenhangscomponent in G r zitten: bottleneck is meer dan r. Trek alle kanten met gewicht hooguit r samen, en ga in recursie.


Download ppt "Netwerk Algorithms: Shortest paths1 Shortest paths II Network Algorithms 2004."

Verwante presentaties


Ads door Google