Advanced Graph Topics

Strongly connected components, bridges and articulation points, and Euler paths for harder rounds and competitive programming.

Advanced · about 8 hours · difficulty 5/5

Learn first: Topological Sort

These algorithms rarely appear in standard placement tests but come up at top product companies and in contests. Learn them once core graphs feel comfortable.

Strongly connected components

In a directed graph, an SCC is a maximal set of nodes where every node can reach every other. Kosaraju's algorithm runs DFS to get finishing order, reverses all edges, then runs DFS in decreasing finish order; each tree found is one SCC. Tarjan's algorithm finds them in one DFS using discovery times and low-links. Compressing SCCs into single nodes produces a DAG, which enables DP on top.

Bridges and articulation points

A bridge is an edge whose removal disconnects the graph; an articulation point is such a vertex. Both come from a DFS that tracks tin[u] (discovery time) and low[u] (earliest time reachable using one back edge). An edge u-v is a bridge if low[v] > tin[u]. LeetCode's Critical Connections in a Network is exactly this.

Euler paths

A path that uses every edge exactly once exists when zero or two vertices have odd degree (undirected). Hierholzer's algorithm constructs it; Reconstruct Itinerary is the classic interview version.

Others worth knowing by name

Lowest common ancestor with binary lifting, maximum flow (Ford-Fulkerson / Dinic) and bipartite matching.

Key concepts

  • Kosaraju's SCC algorithm
  • Tarjan's SCC algorithm
  • Bridges and articulation points
  • Condensation graph
  • Euler paths and Hierholzer
  • Binary lifting for LCA
  • Max flow basics

Mini project

Solve 5 problems: Critical Connections in a Network, Reconstruct Itinerary, CSES Planets and Kingdoms (SCC), CSES Flight Routes Check, and CSES Company Queries I (binary lifting).

Check yourself

What do tin[u] and low[u] represent in the bridge-finding DFS, and why does low[v] > tin[u] mean u-v is a bridge?

Free resources