Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

Shortest Path Problem Is A Problem of Finding The

The document discusses shortest path algorithms and their applications. It describes different types of shortest path problems including single-pair, single-source, single-destination, and all-pairs problems. It provides details on the single-source shortest path problem, how Dijkstra's algorithm and Bellman-Ford algorithm can solve it, and their applications in areas like routing.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Shortest Path Problem Is A Problem of Finding The

The document discusses shortest path algorithms and their applications. It describes different types of shortest path problems including single-pair, single-source, single-destination, and all-pairs problems. It provides details on the single-source shortest path problem, how Dijkstra's algorithm and Bellman-Ford algorithm can solve it, and their applications in areas like routing.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

 Shortest path problem is a problem of finding the shortest path(s) between vertices

of a given graph.
 Shortest path between two vertices is a path that has the least cost as compared
to all other existing paths.
 

Shortest Path Algorithms-


 
Shortest path algorithms are a family of algorithms used for solving the shortest path
problem.
 

Applications-
 
Shortest path algorithms have a wide range of applications such as in-
 Google Maps
 Road Networks
 Logistics Research
 

Types of Shortest Path Problem-


 
Various types of shortest path problem are-
 
 

1. Single-pair shortest path problem


2. Single-source shortest path problem
3. Single-destination shortest path problem
4. All pairs shortest path problem
 

Single-Pair Shortest Path Problem-


 
 It is a shortest path problem where the shortest path between a given pair of
vertices is computed.
 A* Search Algorithm is a famous algorithm used for solving single-pair shortest
path problem.
 

Single-Source Shortest Path Problem-


 
 It is a shortest path problem where the shortest path from a given source vertex to
all other remaining vertices is computed.
 Dijkstra’s Algorithm and Bellman Ford Algorithm are the famous algorithms used
for solving single-source shortest path problem.
 

Single-Destination Shortest Path Problem-


 
 It is a shortest path problem where the shortest path from all the vertices to a
single destination vertex is computed.
 By reversing the direction of each edge in the graph, this problem reduces to
single-source shortest path problem.
 Dijkstra’s Algorithm is a famous algorithm adapted for solving single-destination
shortest path problem.
 

What is Single Source Shortest


Path?
by Team Goseeko 06/07/2021

Features of Single Source Shortest Path


 Single Source Shortest Path is Weighted graph directed.
 Edges may have adverse costs.
 No loop whose price is < 0.0.
 Find the shortest path to each of the n vertices of the digraph from a given source
vertex.
 Where there are negative-cost edges, Dijkstra’s O(n2) single-source greedy algorithm
does not work.
 The Bellman-Ford algorithm finds the bottom-up gap. It first finds certain distances
in the route that have only one edge. Increase the length of the route after that to
find all possible solutions.

Single Source Shortest Path Problem

Given a non-negative linked directed graph G with a non-negative graph Edge


weights and root vertex r, find a directed path P(x) from r to x for each vertex x, such
that the sum of the edge weights in path P(x) is as small as possible. 

In 1959, by the Dutch computer scientist Edsger Dijkstra.

Solves a graph with non-negative edge weights for the single-source shortest path
problem.

In routing, this algorithm is also used.

E.g.: The algorithm of Dijkstra is generally the working theory behind the link-state. 
Protocols of Routing

Bellman-ford Algorithm

 All-destinations of single-source shortest paths in


 Digraphs with cost-negative edges.
 Dynamic programming is used.
 Runs when adjacency matrices are used in O(n3) time.
 Runs in O(ne) time while using adjacency lists.

Algorithm
bellmanFord(dist, pred, source)

Input − Distance list, predecessor list and the source vertex.

Output − True, when a negative cycle is found.

Begin

   iCount := 1

   maxEdge := n * (n – 1) / 2 //n is the number of vertices

   for all vertices v of the graph, do

      dist[v] := ∞

      pred[v] := ϕ

   done

   dist[source] := 0

   eCount := number of edges present in the graph

   create edge list named edgeList

   while iCount < n, do


   for i := 0 to eCount, do

      if dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i)

         dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i)

         pred[edgeList[i].v] := edgeList[i].u

      done

   done

   iCount := iCount + 1

   for all vertices i in the graph, do

      if dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i), then

         return true

      done

   return false

End
What is Single Source Shortest
Path?
by Team Goseeko 06/07/2021

Features of Single Source Shortest Path

 Single Source Shortest Path is Weighted graph directed.


 Edges may have adverse costs.
 No loop whose price is < 0.0.
 Find the shortest path to each of the n vertices of the digraph from a given source
vertex.
 Where there are negative-cost edges, Dijkstra’s O(n2) single-source greedy algorithm
does not work.
 The Bellman-Ford algorithm finds the bottom-up gap. It first finds certain distances
in the route that have only one edge. Increase the length of the route after that to
find all possible solutions.

Single Source Shortest Path Problem

Given a non-negative linked directed graph G with a non-negative graph Edge


weights and root vertex r, find a directed path P(x) from r to x for each vertex x, such
that the sum of the edge weights in path P(x) is as small as possible. 

In 1959, by the Dutch computer scientist Edsger Dijkstra.

Solves a graph with non-negative edge weights for the single-source shortest path
problem.

In routing, this algorithm is also used.

E.g.: The algorithm of Dijkstra is generally the working theory behind the link-state. 
Protocols of Routing
Bellman-ford Algorithm

 All-destinations of single-source shortest paths in


 Digraphs with cost-negative edges.
 Dynamic programming is used.
 Runs when adjacency matrices are used in O(n3) time.
 Runs in O(ne) time while using adjacency lists.

Algorithm

bellmanFord(dist, pred, source)

Input − Distance list, predecessor list and the source vertex.

Output − True, when a negative cycle is found.

Begin

   iCount := 1

   maxEdge := n * (n – 1) / 2 //n is the number of vertices

   for all vertices v of the graph, do

      dist[v] := ∞

      pred[v] := ϕ

   done
   dist[source] := 0

   eCount := number of edges present in the graph

   create edge list named edgeList

   while iCount < n, do

   for i := 0 to eCount, do

      if dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i)

         dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i)

         pred[edgeList[i].v] := edgeList[i].u

      done

   done

   iCount := iCount + 1

   for all vertices i in the graph, do

      if dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i), then

         return true
      done

   return false

End

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

 What is machine learning?


 Define data structure?
 What is recursion?
 Explain SQL?
 What is compilers?
SHARE
 0 

previous post

WHAT IS FERROCEMENT?

next post

WHAT IS PROGRAMMING?

YOU MAY ALSO LIKE

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

 What is machine learning?


 Define data structure?
 What is recursion?
 Explain SQL?
 What is compilers?
SHARE
 0 

previous post
WHAT IS FERROCEMENT?

next post

WHAT IS PROGRAMMING?

YOU MAY ALSO LIKE

What is Single Source Shortest


Path?
by Team Goseeko 06/07/2021

Features of Single Source Shortest Path

 Single Source Shortest Path is Weighted graph directed.


 Edges may have adverse costs.
 No loop whose price is < 0.0.
 Find the shortest path to each of the n vertices of the digraph from a given source
vertex.
 Where there are negative-cost edges, Dijkstra’s O(n2) single-source greedy algorithm
does not work.
 The Bellman-Ford algorithm finds the bottom-up gap. It first finds certain distances
in the route that have only one edge. Increase the length of the route after that to
find all possible solutions.

Single Source Shortest Path Problem

Given a non-negative linked directed graph G with a non-negative graph Edge


weights and root vertex r, find a directed path P(x) from r to x for each vertex x, such
that the sum of the edge weights in path P(x) is as small as possible. 

In 1959, by the Dutch computer scientist Edsger Dijkstra.


Solves a graph with non-negative edge weights for the single-source shortest path
problem.

In routing, this algorithm is also used.

E.g.: The algorithm of Dijkstra is generally the working theory behind the link-state. 
Protocols of Routing

Bellman-ford Algorithm

 All-destinations of single-source shortest paths in


 Digraphs with cost-negative edges.
 Dynamic programming is used.
 Runs when adjacency matrices are used in O(n3) time.
 Runs in O(ne) time while using adjacency lists.

Algorithm

bellmanFord(dist, pred, source)

Input − Distance list, predecessor list and the source vertex.

Output − True, when a negative cycle is found.

Begin

   iCount := 1

   maxEdge := n * (n – 1) / 2 //n is the number of vertices


   for all vertices v of the graph, do

      dist[v] := ∞

      pred[v] := ϕ

   done

   dist[source] := 0

   eCount := number of edges present in the graph

   create edge list named edgeList

   while iCount < n, do

   for i := 0 to eCount, do

      if dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i)

         dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i)

         pred[edgeList[i].v] := edgeList[i].u

      done

   done
   iCount := iCount + 1

   for all vertices i in the graph, do

      if dist[edgeList[i].v] > dist[edgeList[i].u] + (cost[u,v] for edge i), then

         return true

      done

   return false

End

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

 What is machine learning?


 Define data structure?
 What is recursion?
 Explain SQL?
 What is compilers?
SHARE
 0 

previous post

WHAT IS FERROCEMENT?

next post

WHAT IS PROGRAMMING?

YOU MAY ALSO LIKE


All Pairs Shortest Path Problem-
 
 It is a shortest path problem where the shortest path between every pair of vertices
is computed.
 Floyd-Warshall Algorithm and Johnson’s Algorithm are the famous algorithms used
for solving All pairs shortest path problem.
 

Also Read- Floyd-Warshall Algorithm


 

Next Article- Dijkstra’s Algorithm


 
Get more notes and other study material of Design and Analysis of Algorithms.
Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary

Article Name
Shortest Path Problem | Shortest Path Algorithms | Examples

Description
Shortest Path Problem in Data Structure is a problem of finding the shortest path between vertices
of a given graph. Shortest Path Algorithms are a family of algorithms used for solving Shortest
Path Problem. Examples.

Author
Akshay Singhal

Publisher Name
Gate Vidyalay

Publisher Logo

You might also like