






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Task: given a graph G, find the shortest path from a vertex u to a vertex v.
CS 310 Graph Algorithms, Page 2 ' $
Let G = (V, E) be a graph where V comprises a set of cities interconnected by a set of roads (edges) in E.
CS 310 Graph Algorithms, Page 4 ' $
0
1
5
2
3
4
0
1
5
2
3
4
2 9 6
15
8 1 3 7
3
0 1 2 3 4 5 Pred
Whenever dist[v] is set to dist[u] + weight(u, v), P red[v] is set to u.
CS 310 Graph Algorithms, Page 8 ' $
0
(^1 )
3
4 5 6
3
8
5
7
4
8
2
(^0 1 2 3 4 ) Pred
6
0 1 2 3 4 5 6 Dist
Let G = (V, E) be a graph where V is a set of cities and E a set of planned, but not yet constructed, roads to connect cities in V. Let the weight of a road/edge be the cost to construct the road. Problem: using minimum cost, construct a set of roads to connect all the cities. 0
3
8
5
7
4
8
2
(^615)
CS 310 Graph Algorithms, Page 10 ' $
Pred
0 1 2 3 4 5 6
0 1 2 3 4 5 6 Cost
0
(^1 )
3
4 5 6
3
8
5
7
4
8
2
(^615)
CS 310 Graph Algorithms, Page 14 ' $
0
1
5
2
3
4
2 9 6 15
(^81 ) 7
3
neighbor weight next 1 2 5 9 5 6 3 15 2 8 3 1
3 3 2 7 4 3
0 1 2 3 4 5
CS 310 Graph Algorithms, Page 16 ' $
A DAG is a directed graph containing no cycles.
A
D
B
C E
CS 310 Graph Algorithms, Page 20 ' $