Skip to content
  • Dashboard
  • Review
  • Go: plan & chat
  • Roadmap
  • Patterns & lessons49
  • Sheets
  • Problems1.5k
  • Ascend
  • Toolkit
  • Core CS + SQL
  • System Design
  • Machine Coding
  • Interview hub
  • Mock interview
  • Companies & OA
  • Leaderboard
  • Battles
  • College Cup
  • People

Keep your progress

Sync across devices with a free account.

Sign upSign in
Patterns & lessons
Sign inSign up
Patterns/Graphs/Graph BFS / DFS

Pattern

Bridges & Articulation Points (low-link)

In one DFS compute low[v] (earliest discovery time reachable via one back edge) to find edges/vertices whose removal disconnects the graph.

Learn firstGraph BFS / DFS
0%
mastery
0/8 solved
Practise nextForbidden Cities
IdeaPracticePitfalls

Recognise it

The signal

critical connections / necessary roads

  1. 1Brute force

    Remove each edge/vertex and test connectivity: O(E (V + E)).

  2. 2The observation

    Repeated connectivity tests: low-link values summarise back edges.

  3. 3Why it works

    Edge (p, v) is a bridge iff low[v] > tin[p]; vertex p (non-root) is a cut vertex iff some child has low[v] >= tin[p].

Reach for it when

  • +critical cities / single points of failure
  • +2-edge-connected components

Not when

  • ×directed graphs (use scc / dominators)

Practice

Next

Forbidden Cities

0/8 solved
  • Strongly Connected EdgesCSESMedium
  • Necessary RoadsCSESMedium
  • Necessary CitiesCSESMedium
  • Forbidden CitiesCSESHard
  • TouristsCodeforces3200
  • Critical Connections in a NetworkHard
  • We Need More BossesCodeforces2100
  • Minimum Number of Days to Disconnect IslandHard

Pitfalls

Misconceptions

  • !skipping the parent EDGE vs parent VERTEX (breaks with multi-edges)
Go deepervariants and techniques · 2 combinations · resources

Variants and techniques

  • Block-Cut Tree / Bridge TreeCP 2400+Compress the graph into a tree of biconnected blocks and articulation points (or of 2-edge-connected components joined by bridges). Questions like 'must every u-v path pass through c' become tree-path and LCA queries.

Combinations

  • Bridges & Articulation Points (low-link)+Graph BFS / DFS

    critical connections / necessary roads / cities

    Bridges & Articulation Points (low-link):
    low-link comparison to classify edges/vertices
    Graph BFS / DFS:
    single DFS with timestamps

    Critical Connections in a NetworkNecessary RoadsNecessary Cities

  • Block-Cut Tree / Bridge Tree+Binary Lifting & LCA

    queries: can a reach b without visiting c (undirected)

    Block-Cut Tree / Bridge Tree:
    turns 'must pass through c' into a tree-path membership test
    Binary Lifting & LCA:
    LCA / ancestor checks for the path test

    Forbidden Cities

Resources

  • Graph Theory playlistWilliam Fiset · video
  • Graph TraversalUSACO Guide · course
  • Disjoint Set Unioncp-algorithms · article
  • Dijkstracp-algorithms · article
  • Topological sortingcp-algorithms · article
  • Shortest paths visualizerVisuAlgo · tool
  • Graph cheatsheetTech Interview Handbook · article
TodayReviewPatternsProblems