Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.

Similar presentations


Presentation on theme: "Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm."— Presentation transcript:

1 Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm

2 2 Problem Definition & Assumptions Problem: Given a network G = (N, A) in which each arc (i, j) has an associated length or cost c ij, let node s be the source. The length of a directed path is the sum of the lengths of the arcs in the path. For every node i  s, find a shortest length directed path from s to i. Assumptions: –All arc lengths are integers (if rational but not integer, multiply them by a suitably large number) –The network contains a directed path from node s to every node i  s (if not, add an arc (s, i) with very large cost) –The network does not contain a negative cycle (otherwise see Ch. 5) –The network is directed (transform undirected arcs w/positive costs as in Ch. 2; undirected arcs w/negative costs will create neg. cycles)

3 3 Types of Shortest Path Problems Single-source shortest path One node to all others with nonnegative arc lengths – Chapter 4 Variations: maximum capacity path, maximum reliabiltiy path One node to all others with arbitrary arc lengths – Chapter 5 All-pairs shortest path: every node to every other node – Chapter 5 String model for shortest path from s to t: Arcs = strings, knots = nodes; hold s and t and pull tight. Shortest paths will be taut: for i and j on a shortest path connected by arc (i, j), distance s-i plus c ij  distance s-j Associated “dual” maximization problem: pulling s and t as far apart as possible

4 4 Single-Source Shortest Paths Solution is a shortest-path tree rooted at s. Property 4.1. If the path s = i 1 – i 2 – … – i h = k is a shortest path from s to k, then for every q = 2, 3, …, h-1, the subpath s = i 1 – i 2 – … – i q is a shortest path from the source node to i q. Property 4.2. Let the vector d represent the shortest path distances. Then a directed path P from s to k is a shortest path if and only if for Store the shortest path tree as a vector of n-1 predecessor nodes: pred(j) is the node i that satisfies above equality.

5 5 Acyclic Networks: Reaching Examine the nodes in topological order; perform a breadth-first search to find a shortest-path tree. Reaching Algorithm: 0. d(s)  0, d(j)  for j  s, i  s 1. If A(i) is empty, then stop. Otherwise, to examine node i, scan the arcs in A(i). If for any arc (i, j), d(j)  d(i) + c ij, then set d(j) = d(i) + c ij. 2. Set i to the next node in topological order and return to 1. Solves shortest path problem on acyclic networks in O(m) time.

6 6 Dijkstra’s Algorithm Shortest paths from source node to all other nodes with nonnegative arc lengths (cycles permitted) Output: d(i) is the distance from s to i along a shortest path pred(i) is the predecessor of i along a shortest path Intermediate: S = set of permanently labeled nodes (L in GIDEN) set of temporarily labeled nodes (P in GIDEN) GIDEN also has set U for unlabeled nodes At each iteration, one node moves to S from

7 7 Dijkstra’s Algorithm in GIDEN

8 8 Complexity Node selection requires time proportional to Distance updates are performed for each arc emanating from node i; total of m updates in the entire algorithm Since For dense networks, –Complexity can be improved for sparse networks by cleverness and special data structures


Download ppt "Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm."

Similar presentations


Ads by Google