BellmanFord Algorithm
is slower than Dijkstra. But it can handle graph contains a negative cycle.
Time Complexity: E * V
 E is the number of edges
 V is the number of vertexs
Implementation
Python
1  #!/usr/local/bin/python3 
1 

regular graph with negative weight
++ ++
+2—–>+1 4+<–+
 +++ +++ 
+++  ++ ^ 
0 +–3—–>+3+—(1)+ 
+++ ++ 
 ++ 
+–5—>+2+—————10——+
++
negative cycle
++ ++
+2—–>+1+<——(1)——+4+<–+
 +++ +++ 
+++  ++ ^ 
0 +(1)—>+3+—(1)+ 
+++ ++ 
 ++ 
+–5—>+2+—————10——+
++
```