Finding Bridges (Cut Edges)
Find edges whose removal disconnects graph. Similar to articulation points but for edges. Tarjan's algorithm with low-link values.
Visualization
Interactive visualization for Finding Bridges (Cut Edges)
Interactive visualization with step-by-step execution
Implementation
1class BridgeFinder {
2 private time = 0;
3 private disc: Map<number, number> = new Map();
4 private low: Map<number, number> = new Map();
5 private bridges: Array<[number, number]> = [];
6
7 findBridges(graph: Map<number, number[]>): Array<[number, number]> {
8 const visited = new Set<number>();
9
10 for (const v of graph.keys()) {
11 if (!visited.has(v)) {
12 this.dfs(v, -1, graph, visited);
13 }
14 }
15
16 return this.bridges;
17 }
18
19 private dfs(u: number, parent: number, graph: Map<number, number[]>, visited: Set<number>): void {
20 visited.add(u);
21 this.disc.set(u, this.time);
22 this.low.set(u, this.time);
23 this.time++;
24
25 for (const v of graph.get(u) || []) {
26 if (v === parent) continue;
27
28 if (visited.has(v)) {
29 this.low.set(u, Math.min(this.low.get(u)!, this.disc.get(v)!));
30 } else {
31 this.dfs(v, u, graph, visited);
32 this.low.set(u, Math.min(this.low.get(u)!, this.low.get(v)!));
33
34 if (this.low.get(v)! > this.disc.get(u)!) {
35 this.bridges.push([u, v]);
36 }
37 }
38 }
39 }
40}Deep Dive
Theoretical Foundation
Edge (u,v) is bridge if there's no back edge from v's subtree to u or above. Condition: low[v] > disc[u]. Uses DFS to compute discovery time and low-link values.
Complexity
Time
O(V+E)
O(V+E)
O(V+E)
Space
O(V)
Applications
Industry Use
Network vulnerability assessment
Infrastructure critical link identification
Internet routing reliability analysis
Transportation network bottleneck detection
Power grid critical connection analysis
Communication system fault tolerance
Supply chain weak link identification
Use Cases
Related Algorithms
Depth-First Search (DFS)
Graph traversal exploring as deep as possible before backtracking. DFS is a fundamental algorithm that uses a stack (either implicitly through recursion or explicitly) to explore graph vertices. It's essential for cycle detection, topological sorting, and pathfinding problems.
Breadth-First Search (BFS)
Level-by-level graph traversal guaranteeing shortest paths in unweighted graphs. BFS uses a queue to explore vertices level by level, making it optimal for finding shortest paths and solving problems that require exploring nearest neighbors first.
Dijkstra's Algorithm
Finds shortest path from source to all vertices in weighted graph with non-negative edges. Uses greedy approach with priority queue.
Floyd-Warshall Algorithm
Floyd-Warshall is an all-pairs shortest path algorithm that finds shortest distances between every pair of vertices in a weighted graph. Unlike Dijkstra (single-source), it computes shortest paths from all vertices to all other vertices simultaneously. The algorithm can handle negative edge weights but not negative cycles. Developed independently by Robert Floyd, Bernard Roy, and Stephen Warshall in the early 1960s.