1 / 9

Computational Complexity Of The Bellman-Ford Algorithm

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. Complexity Of The Bellman-Ford::premise.

shaun
Télécharger la présentation

Computational Complexity Of The Bellman-Ford Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

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?

More Related