0% found this document useful (0 votes)
152 views5 pages

3.6 Single Source Shortest Paths

The document discusses single source shortest path problems in graphs. It explains that (1) graphs can model transportation networks with vertices as cities and edges as routes between cities. (2) The single source shortest path problem finds the shortest paths from a source vertex to all other vertices. (3) Dijkstra's algorithm is commonly used to solve this problem by iteratively updating the shortest path distances starting from the source.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views5 pages

3.6 Single Source Shortest Paths

The document discusses single source shortest path problems in graphs. It explains that (1) graphs can model transportation networks with vertices as cities and edges as routes between cities. (2) The single source shortest path problem finds the shortest paths from a source vertex to all other vertices. (3) Dijkstra's algorithm is commonly used to solve this problem by iteratively updating the shortest path distances starting from the source.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

SINGLE SOURCE SHORTEST PATH

 Graphs can be used to represent the highway structure of a state or


country with vertices representing cities and edges representing sections
of highway.
 A motorist wishing to drive from city ‘A’ to city ‘B’ would be interested
to find answers to the following questions:
Is there a path from A to B?
If there is more than one path from A to B, which is the
shortest path?
SINGLE SOURCE SHORTEST PATH
 Let G(V, E) be a directed or undirected graph.

 In single source shortest path the shortest path from vertex V0 to all the
remaining vertices is determined.
 The vertex V0 is called source vertex and the last vertex is called destination
vertex.
 The length of the path is defined to be the sum of weights of edges on that
path.
 For example, consider a graph G which is given below:
SINGLE SOURCE Source Destination Path Distance
vertex Vertex
SHORTEST PATH
1 2 1 2 10
1 3 1 2 3 30
1 4 1 2 3 4 45
1 5 1 2 3 5 35
1 6 1 6 30
1 7 1 2 3 5 7 42
30
1 6
35
10 25
20
2 4 7

20 15
12 7

3 5
5
SINGLE SOURCE SHORTEST PATH ALGORITHM
Algorithm Shortestpath(v, dest, cost, n) for( each ‘w’ adjacent to ‘u’ with s[w]=false) do
{ if(dist[w]>dist[u]+cost[u, w]) then
for i:= 1 to n do dist[w]:=dist[u]+cost[u, w];
{ }
s[i]:=false; }
dist[i]:=cost[v,i];
}
s[v]:=true;
dist[v]:=0.0;
for num:=2 to n do
{
Choose ‘u’ from among those
vertices not in ‘S’ such that
dist[u] is minimum.
s[u]:=true;
Discuss the single-source shortest paths algorithm with a suitable
example. [7M] [R16 III-II SET-1 Regular/Supp Oct/Nov - 2020]

Discuss the Dijkstra’s single source shortest path algorithm and derive
its time complexity.[7M][R16 III-II SET-2 Regular April/May -
2019]

You might also like