Data Structure Algorithm, Programming, Dijkstras Algorithm, Bellman Ford Algorithm, Graph.
Graph(5) g.add(0, 1, 5) g.add(0, 2, 4) g.add(1, 3, 3) g.add(2, 1, 6) g.add(3, 2, 2) distance, previous = g.bellmanford(0) for i, (d, p) in enumerate(zip(distance, previous)): print(i, d, p) Implementation in JavaScript class Graph { constructor(vertex) { this.vertex = vertex; this.graph = []; }