Find Bridges (Cut Edges)
Find all bridges in an undirected graph - edges whose removal increases the number of connected components. Similar to articulation points but for edges. Critical for network reliability analysis.
Visualization
Interactive visualization for Find Bridges (Cut Edges)
Interactive visualization with step-by-step execution
Implementation
1function findBridges(graph: Map<number, number[]>, V: number): [number, number][] {
2 const disc = new Map<number, number>();
3 const low = new Map<number, number>();
4 const parent = new Map<number, number | null>();
5 const bridges: [number, number][] = [];
6 let time = 0;
7
8 function dfsBridge(u: number): void {
9 disc.set(u, time);
10 low.set(u, time);
11 time++;
12
13 for (const v of graph.get(u) || []) {
14 if (!disc.has(v)) {
15 parent.set(v, u);
16 dfsBridge(v);
17
18 low.set(u, Math.min(low.get(u)!, low.get(v)!));
19
20 if (low.get(v)! > disc.get(u)!) {
21 bridges.push([u, v]);
22 }
23 } else if (v !== parent.get(u)) {
24 low.set(u, Math.min(low.get(u)!, disc.get(v)!));
25 }
26 }
27 }
28
29 for (let i = 0; i < V; i++) {
30 if (!disc.has(i)) {
31 parent.set(i, null);
32 dfsBridge(i);
33 }
34 }
35
36 return bridges;
37}Deep Dive
Theoretical Foundation
Edge (u,v) is bridge if there's no back edge from v's subtree to u or ancestors. Condition: low[v] > disc[u]. Uses DFS to compute discovery time and low-link values for efficient detection.
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.