Key Graph Algorithms
Key Algorithms on Graphs
Section titled “Key Algorithms on Graphs”Essential graph algorithms for shortest paths, minimum spanning trees, and more. Each major algorithm now has its own detailed page.
Dedicated Pages
Section titled “Dedicated Pages”Each algorithm is explained in depth on its own page:
| Algorithm | Page | Best For |
|---|---|---|
| Dijkstra | Dijkstra’s Algorithm → | Shortest path, non-negative weights |
| Bellman-Ford | Bellman-Ford Algorithm → | Shortest path, handles negative weights |
| Floyd-Warshall | Floyd-Warshall Algorithm → | All-pairs shortest path |
| Topological Sort | Topological Sort → | Ordering DAGs (dependencies, build systems) |
| Union-Find (DSU) | Union-Find (Disjoint Set) → | Track connected components, detect cycles |
| MST (Kruskal & Prim) | Minimum Spanning Tree → | Kruskal vs Prim for MST |
| Cycle Detection | Cycle Detection → | Detect cycles in directed/undirected graphs |
Choosing the Right Algorithm
Section titled “Choosing the Right Algorithm”flowchart TD Q1{What problem?} Q1 --> SP[Shortest Path] Q1 --> MST[Minimum Spanning Tree] Q1 --> Other[Structure / Order]
SP --> SP1{Edge weights?} SP1 -->|Unweighted| BFS["BFS O(V+E)"] SP1 -->|Non-negative| DIJK["Dijkstra O((V+E) log V)"] SP1 -->|Negative edges| BF["Bellman-Ford O(V×E)"] SP1 -->|All pairs| FW["Floyd-Warshall O(V³)"]
MST --> MST1{Graph density?} MST1 -->|Sparse| KRUS["Kruskal's O(E log E)"] MST1 -->|Dense| PRIM["Prim's O((V+E) log V)"]
Other --> O1{Detect cycles?} Other --> O2{Order dependencies?} Other --> O3{Connected components?} O1 --> CYCLE["Cycle Detection →"] O2 --> TOPO["Topological Sort →"] O3 --> UF["Union-Find (DSU) →"]
style BFS fill:#4f46e5,color:#fff style DIJK fill:#7c3aed,color:#fff style BF fill:#4f46e5,color:#fff style FW fill:#6366f1,color:#fff style KRUS fill:#059669,color:#fff style PRIM fill:#059669,color:#fff style CYCLE fill:#dc2626,color:#fff style TOPO fill:#dc2626,color:#fff style UF fill:#dc2626,color:#fffNext Steps
Section titled “Next Steps”Apply these algorithms using our Problem-Solving Approach and check the Code Examples for implementations.
Related Topics
Section titled “Related Topics”- Tree Algorithms — Compare tree and graph traversal approaches