You are on page 1of 19

Shortest Path

Unit -5
Single-Source Shortest Paths
Single-Source Shortest Paths
Single-Source Shortest Paths
Dijkstra’s algorithm
Dijkstra’s algorithm
Dijkstra’s algorithm
All-Pairs Shortest Paths
The Floyd-Warshall algorithm
• We will use a different dynamic-programming
formulation to solve the all-pairs shortest-
paths problem on a directed graph G =(V, E).
The resulting algorithm, known as the Floyd-
Warshall algorithm, runs in theta (V3)time. As
before, negative-weight edges may be
present, but we assume that there are no
negative-weight cycles.
The structure of a shortest path
• The Floyd-Warshall algorithm considers the
intermediate vertices of a shortest path,
where an intermediate vertex of a simple path
p =<v1, v2,….vl> is any vertex of p other than
v1 or vl, that is, any vertex in the set <v2, v3,
…….vl>.
The structure of a shortest path
The structure of a shortest path
The structure of a shortest path
The structure of a shortest path
The structure of a shortest path
shortest path
The structure of a shortest path
The structure of a shortest path
The structure of a shortest path

You might also like