> For the complete documentation index, see [llms.txt](https://liuzhenglaichn.gitbook.io/algorithm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuzhenglaichn.gitbook.io/algorithm/graph/shortest-path.md).

# Shortest Path

| Algorithm      | Time Complexity                                                | Usecase              | Memo                                                                |
| -------------- | -------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------- |
| Bellman-Ford   | O(VE)                                                          | Single Source to All | Use all the edges to relax `V-1` times                              |
| Dijkstra       | <p>O(ElogE) with heap.<br>O(E + VlogV) with Fabonacci Heap</p> | Single Source to All | Heap with closest nodes                                             |
| Floyd-Warshall | O(V^3)                                                         | All to All           | Use each node as a intermediate node to update `N^2` pairs of nodes |
