■ Graph Learning Path (Stage-wise)
Stage 1: Fundamentals (Representation & Basics)
Before diving into algorithms, understand how to store and traverse graphs.
Core Concepts:
• Graph types: Directed vs. Undirected, Weighted vs. Unweighted, Cyclic vs. Acyclic, Dense vs. Sparse
• Representation: Adjacency Matrix (O(V²)), Adjacency List (O(V+E))
• Terminology: Degree, Path, Cycle, Connected components
Techniques to Learn:
• Depth First Search (DFS)
• Breadth First Search (BFS)
• Recursive & iterative implementations
• Detecting connected components (DFS/BFS)
• Graph traversal order
Goal: Comfortably build & traverse graphs.
Stage 2: Core Graph Algorithms
This is the must-know toolkit for 90% of problems.
Traversal & Search:
• BFS shortest path in unweighted graph
• DFS cycle detection (directed & undirected)
• Topological Sort (Kahn’s Algorithm, DFS method)
Shortest Path Algorithms:
• Dijkstra’s Algorithm (single source shortest path, non-negative weights)
• Bellman-Ford Algorithm (handles negative weights, detect negative cycles)
• Floyd-Warshall Algorithm (all-pairs shortest path)
Minimum Spanning Tree (MST):
• Prim’s Algorithm
• Kruskal’s Algorithm (+ Disjoint Set Union / Union-Find)
Stage 3: Advanced Graph Algorithms
Once you master Stage 2, you can tackle more complex graph problems.
Flow & Matching:
• Ford-Fulkerson / Edmonds-Karp (Maximum flow)
• Bipartite Graph Check (DFS/BFS coloring)
• Hopcroft–Karp (Maximum matching in bipartite graphs)
Special Graphs & Techniques:
• Tarjan’s Algorithm: Strongly Connected Components (SCC), Articulation Points & Bridges
• Kosaraju’s Algorithm (SCC)
• Topological Sort in DAG shortest/longest paths
• Johnson’s Algorithm (all-pairs shortest path for sparse graphs)
Stage 4: Problem-Solving Patterns
Here’s where you mix and match techniques for competitive programming / real-world problems.
• Grid-based graph problems (convert matrix to graph)
• Multi-source BFS
• 0–1 BFS (using deque for edges with weights 0 or 1)
• Dijkstra with priority queue
• DFS + Backtracking in graphs (Hamiltonian paths, Knight’s tour)
• Topological sort with extra constraints
• Binary Search on Answer + BFS/DFS (minimum path threshold problems)
• Minimum Spanning Tree variations (second-best MST, dynamic MST)
• Union-Find with path compression & union by rank
• Bitmask DP on graphs (TSP, subset problems)
Suggested Learning Order
• Basics & Representation → DFS, BFS, connected components
• Shortest Path & MST → Dijkstra, Bellman-Ford, Prim, Kruskal
• Topological Sort & DAG problems
• SCC & Bridges → Tarjan, Kosaraju
• Flow algorithms → Ford-Fulkerson, Edmonds-Karp, Bipartite matching
• Advanced optimizations → 0–1 BFS, Johnson’s, Binary Search on graphs
• Problem Patterns → Practice mixed-technique problems