Graphs: Shortest Paths: Atul Gupta
Graphs: Shortest Paths: Atul Gupta
Find Cycles Euler Path and Circuit Problem Hamiltonian Path and Circuit Problem (or TSP)
Shortest Path
Given a weighted graph G(V, E) with weight function w: E R Weight w(p) of path p (v0, v1, v2, , vk) is given by
A shortest path between two nodes will be a path with minimum w(p)
Shortest Paths
Main Idea: Relaxing edges in the graph
Two cases
(a)
(b)
Dijkestras Algorithm
Stacks
11
Bellman-Ford Algorithm
Summary
Here we presented two algorithms for single source shortest paths
Dijkestras Bellman-Fords
Both make use of Edge Relaxation approach Dijkestras algorithm is faster but can not be used with graphs having negative weight edges Bellman-Fords algorithm can work with graphs having negative weight edges but not the negative cycles The Dijkestra algorithm is an example of greedy approach.
Cormens Book