Pawan Kumar
Tiwari
MCA 3 sem
Roll NO. 16
A Review And Evaluations
Of Shortest Path Algorithms
Introduction
 The shortest path problem is a problem of finding the
shortest path or route from a starting point to a final
destination.
 Shortest path problem we use graphs. A graph is a
mathematical abstract object.
 Lengths of edges are often called weights, and the weights
are normally used for calculating the shortest path from one
point to another point.
 For example, in order to represent a map we can use a
graph, where vertices represent cities and edges represent
routes that connect the cities.
 If routes are one-way then the graph will be directed;
otherwise, it will be undirected.
 Different types of algorithms that solve the shortest
path problem.
Dijkstra’s Algorithm
Floyd-Warshall Algorithm
Bellman-Ford Algorithm
Genetic Algorithm (GA)
Dijkstra’s Algorithm
 It’s a greedy algorithm.
 Dijkstra's algorithm is called the single-source shortest
path. It is also known as the single source shortest path
problem. It computes length of the shortest path from the
source to each of the remaining vertices in the graph.
 In Dijkstra's solve the problem on a weighted directed
graph from for case in which all edge width’s are non
negative.
 Dijkstra’s algorithm uses the greedy approach to solve the
single source shortest problem.
 Breadth-first-search is an algorithm for finding shortest (link-
distance) paths from a single source vertex to all other
vertices.
Algorithm of Dijkstra’s
// a little miss leading since the output is only the distance
Algorithm: ShortestPath(G, v)
input: A simple undirected weighted graph G
with non negative edge weights and a start vertex, v.
output: D(u) the distance u is from v.
Initialize D(v) = 0 and D(u) = ∞ for u != v
Initialize priority queue Q of vertices using D as key.
while Q is not empty do
u = Q.removeMin()
for each vertex z adjacent to u and in Q do
if D(u) + w((u, z)) < D(z) then
D(z) = D(u) + w((u, z))
update z in Q
return D
Example
Apply
Dijkstra
Advantage
 If a Fibonacci heap was used then the complexity is O(|E| + |V|log|
V| ) , which is the best bound. The DeleteMins operation takes
O(log|V|).
 If a standard binary heap is used then the complexity is O( | E |log
|E|),| E | log |E| term comes from|E|updates for the standard heap
Disadvantage
 The major disadvantage of the algorithm is the fact that it does a
blind search there by consuming a lot of time waste of necessary
resources.
 Another disadvantage is that it cannot handle negative edges. This
leads to acyclic graphs and most often cannot obtain the right
shortest path.
APPLICATIONS
 Traffic information systems use Dijkstra’s algorithm in
order to track the source and destinations from a given
particular source and destination.
 Telephone Network
 Flight Agenda
 OSPF- Open Shortest Path First, used in Internet routing.
It uses a link-state in the individual areas that make up
the hierarchy. The computation is based on Dijkstra's
algorithm which is used to calculate the shortest path tree
inside each area of the network.
Floyd-Warshall Algorithm
 The Floyd–Warshall algorithm is an example of dynamic
programming, and was published in its currently recognized form by
Robert Floyed in 1962.
 It is also known as all pair shortest path problem.
 Floyd–Warshall algorithm is an algorithm for finding shortest paths
in a weighted graph with positive or negative edge weights (but with
no negative cycles).
 If requires n iteration after iteration k ,A(Cost Matrix), gives the
length of the shortest path that only uses nodes {1,2,..k} as
intermediate nodes at iteration k the algorithm must check for each
pair of nodes (i , j) whether or not their exist a path from i to j passing
through vertex k that is better than the present optional path
through nodes in {1,2,..k-1}, Hence
A k [i , j]=min{ Ak-1[i , j] ,Ak-1[i , k] +Ak-1[k , j] }
Where k>=1
Algorithm …
//cost [1:n,1:n] is the cost adjacency matrix of the graph with n
vertices .
//A[i , j] is the cost of the shortest path from vertex i to 1.
Cost [i , j ]=0 to n do
for i1 to n do
for j 1 to n do
A[i , j] cost [i , j] //copy cost into A
end for
end for
for k 1 to n do
for i1 to n do
for j 1 to n do
A[i ,j] min{A[ i , j ],A[ i , k ]+A[ k ,j ] }
end for
end for
end for
return (A)
end algorithm
n*n
n*n*n
Total time is
𝜽(n3)
Example 1
2
4
3
4
2-1
3
-2
Application
 Shortest paths in directed graphs (Floyd’s
algorithm).
 Finding a regular expression denoting the regular
language accepted by a finite automaton
(Kleene’s algorithm)
 Fast computation of Pathfinder networks.
 Maximum Bandwidth Paths in Flow Networks
Genetic Algorithm
 Genetic Algorithms were invented to mimic some of the processes
observed in natural evolution.
 The idea with GA is to use this power of evolution to solve optimization
problems.
 The father of the original Genetic Algorithm was John Holland who
invented it in the early 1970's.
 Genetic Algorithms (GAs) are adaptive heuristic search algorithm
based on the evolutionary ideas of natural selection and genetics.
 In order to solve the shortest path problem using the GA, we need to
generate a number of solutions, and then choose the most optimal one
among the provided set of possible solutions.
 Useful when search space very large or too complex for analytic
treatment.
Why genetic algorithm ?
 It is better than conventional AI in that it is more
robust. Unlike older AI systems, they do not break easily
even if the inputs changed slightly, or in the presence of
reasonable noise. Also, in searching a genetic
algorithm may offer significant benefits over more
typical search of optimization techniques.
 GN are also used to graph coloring problem.
Evolutionary Principles of Genetic Algorithms
Selection – or survival of the fittest or giving
preference to better outcomes
Give preference to better individuals, allowing them to pass
on their genes to the next generation.
The goodness of each individual depends on its fitness.
Fitness may be determined by an objective function or by a
subjective judgement.
Crossover – combining portion of good outcomes to create even
better outcomesPrime distinguished factor of GA from other
optimization techniques
 Two individuals are chosen from the population using the selection
operator
 A crossover site along the bit strings is randomly chosen
 The values of the two strings are exchanged up to this point
 If S1=000000 and s2=111111 and the crossover point is 2 then
S1'=110000 and s2'=001111
 The two new offspring created from this mating are put into the next
generation of the population
 By recombining portions of good individuals, this process is likely to
create even better individuals
Mutation – randomly trying combinations and evaluating
the success of each
 With some low probability, a portion of the new individuals
will have some of their bits flipped.
 Its purpose is to maintain diversity within the population and
inhibit premature convergence.
 Mutation alone induces a random walk through the search
space
 Mutation and selection (without crossover) create a parallel,
noise-tolerant, hill-climbing algorithms
Advantage
 It can solve every optimisation problem which can be
described with the chromosome encoding.
 It solves problems with multiple solutions.
 Structural genetic algorithm gives us the possibility to solve
the solution structure and solution parameter problem at the
same time by means of genetic algorithm.
 Genetic algorithm are easily transferred to existing simulation
and models.
Disadvantages
 Certain optimisation problems(they are called variant
problems) can not be solved by means of GA, this occurs due
to poorly known fitness function which generate bad
chromosome block in spite of the fact that only good
chromosome blocks cross-over.
 There is no absolute assurance that a GA will find a global
optimum . It happens very often when the populations have a
 If you have enough memory and time, Floyd-Warshall is clearly
better because it takes much less time to code. But if you don't
want every possible path, Floyd-Warshall may waste time by
calculating too many unwanted shortest paths .In that case, you
can go with Dijkstra.
 Take thousands or even millions of possible solutions and
combining and recombining them until it finds the optimal
solution.
Conclusion…
Review and evaluations of shortest path algorithms

Review and evaluations of shortest path algorithms

  • 1.
    Pawan Kumar Tiwari MCA 3sem Roll NO. 16 A Review And Evaluations Of Shortest Path Algorithms
  • 2.
    Introduction  The shortestpath problem is a problem of finding the shortest path or route from a starting point to a final destination.  Shortest path problem we use graphs. A graph is a mathematical abstract object.  Lengths of edges are often called weights, and the weights are normally used for calculating the shortest path from one point to another point.  For example, in order to represent a map we can use a graph, where vertices represent cities and edges represent routes that connect the cities.  If routes are one-way then the graph will be directed; otherwise, it will be undirected.
  • 3.
     Different typesof algorithms that solve the shortest path problem. Dijkstra’s Algorithm Floyd-Warshall Algorithm Bellman-Ford Algorithm Genetic Algorithm (GA)
  • 4.
    Dijkstra’s Algorithm  It’sa greedy algorithm.  Dijkstra's algorithm is called the single-source shortest path. It is also known as the single source shortest path problem. It computes length of the shortest path from the source to each of the remaining vertices in the graph.  In Dijkstra's solve the problem on a weighted directed graph from for case in which all edge width’s are non negative.  Dijkstra’s algorithm uses the greedy approach to solve the single source shortest problem.  Breadth-first-search is an algorithm for finding shortest (link- distance) paths from a single source vertex to all other vertices.
  • 5.
    Algorithm of Dijkstra’s //a little miss leading since the output is only the distance Algorithm: ShortestPath(G, v) input: A simple undirected weighted graph G with non negative edge weights and a start vertex, v. output: D(u) the distance u is from v. Initialize D(v) = 0 and D(u) = ∞ for u != v Initialize priority queue Q of vertices using D as key. while Q is not empty do u = Q.removeMin() for each vertex z adjacent to u and in Q do if D(u) + w((u, z)) < D(z) then D(z) = D(u) + w((u, z)) update z in Q return D
  • 6.
  • 7.
    Advantage  If aFibonacci heap was used then the complexity is O(|E| + |V|log| V| ) , which is the best bound. The DeleteMins operation takes O(log|V|).  If a standard binary heap is used then the complexity is O( | E |log |E|),| E | log |E| term comes from|E|updates for the standard heap Disadvantage  The major disadvantage of the algorithm is the fact that it does a blind search there by consuming a lot of time waste of necessary resources.  Another disadvantage is that it cannot handle negative edges. This leads to acyclic graphs and most often cannot obtain the right shortest path.
  • 8.
    APPLICATIONS  Traffic informationsystems use Dijkstra’s algorithm in order to track the source and destinations from a given particular source and destination.  Telephone Network  Flight Agenda  OSPF- Open Shortest Path First, used in Internet routing. It uses a link-state in the individual areas that make up the hierarchy. The computation is based on Dijkstra's algorithm which is used to calculate the shortest path tree inside each area of the network.
  • 9.
    Floyd-Warshall Algorithm  TheFloyd–Warshall algorithm is an example of dynamic programming, and was published in its currently recognized form by Robert Floyed in 1962.  It is also known as all pair shortest path problem.  Floyd–Warshall algorithm is an algorithm for finding shortest paths in a weighted graph with positive or negative edge weights (but with no negative cycles).  If requires n iteration after iteration k ,A(Cost Matrix), gives the length of the shortest path that only uses nodes {1,2,..k} as intermediate nodes at iteration k the algorithm must check for each pair of nodes (i , j) whether or not their exist a path from i to j passing through vertex k that is better than the present optional path through nodes in {1,2,..k-1}, Hence A k [i , j]=min{ Ak-1[i , j] ,Ak-1[i , k] +Ak-1[k , j] } Where k>=1
  • 10.
    Algorithm … //cost [1:n,1:n]is the cost adjacency matrix of the graph with n vertices . //A[i , j] is the cost of the shortest path from vertex i to 1. Cost [i , j ]=0 to n do for i1 to n do for j 1 to n do A[i , j] cost [i , j] //copy cost into A end for end for for k 1 to n do for i1 to n do for j 1 to n do A[i ,j] min{A[ i , j ],A[ i , k ]+A[ k ,j ] } end for end for end for return (A) end algorithm n*n n*n*n Total time is 𝜽(n3)
  • 11.
  • 12.
    Application  Shortest pathsin directed graphs (Floyd’s algorithm).  Finding a regular expression denoting the regular language accepted by a finite automaton (Kleene’s algorithm)  Fast computation of Pathfinder networks.  Maximum Bandwidth Paths in Flow Networks
  • 13.
    Genetic Algorithm  GeneticAlgorithms were invented to mimic some of the processes observed in natural evolution.  The idea with GA is to use this power of evolution to solve optimization problems.  The father of the original Genetic Algorithm was John Holland who invented it in the early 1970's.  Genetic Algorithms (GAs) are adaptive heuristic search algorithm based on the evolutionary ideas of natural selection and genetics.  In order to solve the shortest path problem using the GA, we need to generate a number of solutions, and then choose the most optimal one among the provided set of possible solutions.  Useful when search space very large or too complex for analytic treatment.
  • 14.
    Why genetic algorithm?  It is better than conventional AI in that it is more robust. Unlike older AI systems, they do not break easily even if the inputs changed slightly, or in the presence of reasonable noise. Also, in searching a genetic algorithm may offer significant benefits over more typical search of optimization techniques.  GN are also used to graph coloring problem.
  • 15.
    Evolutionary Principles ofGenetic Algorithms Selection – or survival of the fittest or giving preference to better outcomes Give preference to better individuals, allowing them to pass on their genes to the next generation. The goodness of each individual depends on its fitness. Fitness may be determined by an objective function or by a subjective judgement.
  • 16.
    Crossover – combiningportion of good outcomes to create even better outcomesPrime distinguished factor of GA from other optimization techniques  Two individuals are chosen from the population using the selection operator  A crossover site along the bit strings is randomly chosen  The values of the two strings are exchanged up to this point  If S1=000000 and s2=111111 and the crossover point is 2 then S1'=110000 and s2'=001111  The two new offspring created from this mating are put into the next generation of the population  By recombining portions of good individuals, this process is likely to create even better individuals
  • 17.
    Mutation – randomlytrying combinations and evaluating the success of each  With some low probability, a portion of the new individuals will have some of their bits flipped.  Its purpose is to maintain diversity within the population and inhibit premature convergence.  Mutation alone induces a random walk through the search space  Mutation and selection (without crossover) create a parallel, noise-tolerant, hill-climbing algorithms
  • 18.
    Advantage  It cansolve every optimisation problem which can be described with the chromosome encoding.  It solves problems with multiple solutions.  Structural genetic algorithm gives us the possibility to solve the solution structure and solution parameter problem at the same time by means of genetic algorithm.  Genetic algorithm are easily transferred to existing simulation and models. Disadvantages  Certain optimisation problems(they are called variant problems) can not be solved by means of GA, this occurs due to poorly known fitness function which generate bad chromosome block in spite of the fact that only good chromosome blocks cross-over.  There is no absolute assurance that a GA will find a global optimum . It happens very often when the populations have a
  • 19.
     If youhave enough memory and time, Floyd-Warshall is clearly better because it takes much less time to code. But if you don't want every possible path, Floyd-Warshall may waste time by calculating too many unwanted shortest paths .In that case, you can go with Dijkstra.  Take thousands or even millions of possible solutions and combining and recombining them until it finds the optimal solution. Conclusion…

Editor's Notes

  • #8 History. [Fredman and Tarjan, 1986] ,,,,,,,Ingenious data structure and analysis. ,,Original motivation: improve Dijkstra's shortest path algorithm ,,from O(E log V ) to O(E + V log V ).
  • #13 Kleene's algorithm transforms a given deterministic finite automaton (DFA) into a regular expression. Together with other conversion algorithms, it establishes the equivalence of several description formats for regular languages.
  • #16  different types of selection methods Roulette Wheel selection method is chosen in order to solve the shortest path problem
  • #18 Hill climbing is use a TSP