csnotes/370/notes/single-source.md
2019-04-15 20:06:49 -07:00

488 B

Single Source Shortest Path

Bellman-ford Algorithm

Time: O(VE)

Floyd-Warshall

Space: O(V^2)

That space is because we're using a matrix to store the paths, which of course is going to take up two dimensions

Main idea: Shortest path between any two nodes in a graph w/ V nodes will go through at most V nodes

Iterative idea: Path's can visit i intermediary node. Does that many any path shorter?

Advantages: we can find negative cycles(Cycle where there is a negative edge)