Graphs & Connectivity
Graphs model pairwise relationships between entities. Traversal algorithms explore reachability; topological sorting resolves dependency orders; Union-Find tracks connected components under dynamic edge additions; Kruskal algorithm builds Minimum Spanning Trees (MSTs) by greedily uniting non-cyclic edges.
Key Invariants & Rules
- Breadth-First Search (BFS) discovers vertices in non-decreasing order of edge distance from the source.
- Depth-First Search (DFS) backtracks only when all adjacent vertices from the current path are explored.
- Union-Find root compression flattens tree depth during find, achieving near-constant inverse Ackermann time.
- Kruskal algorithm sorts edges by weight and includes edge (u, v) if and only if find(u) != find(v).
- Topological sort exists if and only if the directed graph contains no directed cycles (DAG).
Must-Know Algorithms
Computes unweighted shortest paths and multi-source wavefront propagation.
Builds minimum connected spanning forest using greedy cycle-check connectivity.
Social collaboration network distance tracking using queue BFS.
Learning Path (11 Lessons)
Self-Check & Concept Review
1. What data structure is essential to implement Breadth-First Search (BFS)?
2. In Kruskal algorithm for Minimum Spanning Trees, how are cycles detected when considering a candidate edge (u, v)?
3. What does a multi-source BFS wavefront compute for every vertex in a graph?
4. When is a topological sort of a directed graph possible?
5. What is the purpose of path compression in the Union-Find find operation?