180 likes | 324 Views
1. Shortest Path From 0 in Weighted DiGraph. 1. 2. 1. 7. 0. 5. 4. 3. 1. 1. 4. 3. 4. 1. 1. Shortest Path From 0 in Weighted DiGraph. 1. 2. 1. 7. 0. 5. 4. 3. 1. 1. 4. 3. 4. 1. Shortest Path From 0 in Weighted DiGraph. MinPriority Queue e dge, weight:. 1.
E N D
1 Shortest Path From 0 in Weighted DiGraph 1 2 1 7 0 5 4 3 1 1 4 3 4 1
1 Shortest Path From 0 in Weighted DiGraph 1 2 1 7 0 5 4 3 1 1 4 3 4 1
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 7 0 5 4 3 1 1 4 3 4 1
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 0-1, 1 7 0-3, 4 0 5 4 3 1 1 4 3 4 1
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 0-1, 1 7 distTo[1] = 1 0-3, 4 0 5 4 3 1 1 4 3 4 1 edgeTo[1] = 0 weight(0-1) = 1 distTo[1] = distTo[0] + weight(0-1) = 0 + 1 = 1
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 7 distTo[1] = 1 0-3, 4 0 5 4 3 1 1 4 3 4 1 edgeTo[1] = 0
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1-2, 1 1 7 distTo[1] = 1 0-3, 4 0 5 4 1-3, 4 3 1 1 4 3 4 1 edgeTo[1] = 0
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1-2, 1 1 7 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 4 1-3, 4 3 1 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 weight(1-2) = 1 distTo[2] = distTo[1] + weight(1-2) = 1 + 1 = 2
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 7 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 4 1-3, 4 3 1 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v 2-3, 1 distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 4 1-3, 4 3 1 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v 2-3, 1 1 2 distTo[0] = 0 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 weight(2-3) = 1 edgeTo[3] = 2 distTo[3] = distTo[2] + weight(2-3) = 2 + 1 = 3
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 edgeTo[3] = 2
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v 3-4, 1 distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 edgeTo[3] = 2
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v 3-4, 1 distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 distTo[4] = 4 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 weight(3-4) = 1 edgeTo[3] = 2 edgeTo[4] = 3 distTo[4] = distTo[3] + weight(3-4) = 3 + 1 = 4
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 distTo[4] = 4 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 edgeTo[3] = 2 edgeTo[4] = 2
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v 4-5, 1 distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 distTo[4] = 4 2-5, 7 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 edgeTo[3] = 2 edgeTo[4] = 2
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v 4-5, 1 distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 distTo[4] = 4 2-5, 7 distTo[5] = 5 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 weight(4-5) = 1 edgeTo[3] = 2 edgeTo[4] = 2 distTo[5] = distTo[4] + weight(4-5) = 4 + 1 = 5 edgeTo[5] = 4
Shortest Path From 0 in Weighted DiGraph MinPriority Queue edge, weight: 1 distTo[v]: distance from 0 to v distTo[0] = 0 1 2 1 7 2-4, 3 distTo[1] = 1 distTo[2] = 2 0-3, 4 0 5 distTo[3] = 3 4 1-3, 4 3 1 distTo[4] = 4 2-5, 7 distTo[5] = 5 1 4 3 4 1 edgeTo[1] = 0 edgeTo[2] = 1 edgeTo[3] = 2 edgeTo[4] = 3 edgeTo[5] = 4