Computational Complexity Of The Bellman-Ford Algorithm - PowerPoint PPT Presentation

shaun
computational complexity of the bellman ford algorithm n.
Skip this Video
Loading SlideShow in 5 Seconds..
Computational Complexity Of The Bellman-Ford Algorithm PowerPoint Presentation
Download Presentation
Computational Complexity Of The Bellman-Ford Algorithm

play fullscreen
1 / 9
Download Presentation
Presentation Description
184 Views
Download Presentation

Computational Complexity Of The Bellman-Ford Algorithm

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Computational Complexity Of The Bellman-Ford Algorithm Alexander c. nwala Introduction to Networks and Communications Dr. Kurt maly Department of computer science Old dominion university

  2. Complexity Of The Bellman-Ford::premise • Dijkstra is more efficient, but cannot handle negative cycles. • Dijkstra is based on centralization: requires knowledge of all nodes participating in the network.

  3. Complexity Of The Bellman-Ford::solution • Bellman-Ford: • Guaranteed to return the shortest path in the absence of negative cycles Or • Report the presence of a negative cycle

  4. Complexity Of The Bellman-Ford::algorithm • Bellman-Ford(G, W, S) • { • Initialize() Relax(u,v,w) • for i = 0 to |V| - 1 { • { if( d[v] > d[u] + w(u,v) ) • foreach edge (u,v) Ɛ E { • { d[v] = d[u] + w(u,v) • Relax(u, v, w) π[v] = u • } } • } } • } • Report_Negative_Cycle • foreach edge (u,v) Ɛ E • { • if( d[v] > d[u] + w(u,v) ) • report negative cycle • }

  5. Complexity Of The Bellman-Ford::complexity • Bellman-Ford(G, W, S) • { • Initialize() Relax(u,v,w) • for i = 0 to |V| - 1 { • { if( d[v] > d[u] + w(u,v) ) • foreach edge (u,v) Ɛ E { • { d[v] = d[u] + w(u,v) • Relax(u, v, w) π[v] = u • } } • } } • } • Report_Negative_Cycle • foreach edge (u,v) Ɛ E O(V) O(E) + O(E) = O(VE) • { • if( d[v] > d[u] + w(u,v) ) • report negative cycle • }

  6. Complexity Of The Bellman-Ford::simulation V = 13 E = 12

  7. Complexity Of The Bellman-Ford::simulation • Algorithm begin • Source vertex is A • Graph initialized • Iteration 1 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 2 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 3 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 4 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 5 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 6 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 7 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 8 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 9 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 10 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 11 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Iteration 12 • Relax A > B • Relax B > C • Relax C > D • Relax B > E • Relax E > F • Relax E > G • Relax F > H • Relax H > K • Relax G > I • Relax I > J • Relax B > L • Relax L > M • Algorithm end V = 13 E = 12 Iterations = 12; (V-1) Total Run = 144; (V-1)E

  8. Glossary • Big – O: • Big-O notation is a description of the behavior of a function when the input grows to infinity. • Edge Relaxation: • “The notion of "relaxation" comes from an analogy between the estimate of the shortest path and the length of a helical tension spring, which is not designed for compression. Initially, the cost of the shortest path is an overestimate, likened to a stretched out spring. As shorter paths are found, the estimated cost is lowered, and the spring is relaxed. Eventually, the shortest path, if one exists, is found and the spring has been relaxed to its resting length.” – krjampani(stackoverflow). • Negative cycle: • This refers to a cycle whose sum is negative

  9. Complexity Of The Bellman-Ford::questions?