Bridges in graph

Graphs Additional Algorithms Hard
  • Fun Fact: The concept of finding "bridges" in a graph is central to network reliability analysis in software-defined networking (SDN)
  • In such networks, nodes represent devices and edges represent connections between them
  • A bridge node or edge is a critical point that, if failed, could interrupt the entire network communication
  • Identifying these bridges helps network engineers to design more reliable systems and take necessary precautions to prevent network failure
  • It's also used in power grid management and social network analysis to identify individuals or connections crucial to the network's overall cohesion

Given an undirected connected Graph with V vertices (Numbered from 0 to V-1) and E edges. An edge is represented [ai, bi] denoting that there is an edge from vertex ai to bi . An edge is called a bridge if its removal makes some vertex unable to reach another vertex.


Return all bridges in the graph in any order.

Examples:


Input: V = 4, E = [ [0,1],[1,2],[2,0],[1,3] ]

Output: [ [1, 3] ]

Explanation: The edge [1, 3] is the critical edge because if we remove the edge the graph will be divided into 2 components.


Input: V = 3, E = [[0,1],[1,2],[2,0]]

Result: []

Explanation: There no bridges in the graph.

Input: V = 2, E = [[0,1]]

Constraints

  • 2 <= V, E <= 104
  • 0 <= ai, bi <= V - 1

Hints

  • Perform a DFS traversal, tracking discovery time (disc[]) and lowest reachable vertex (low[]) for each node.
  • If low[v] > disc[u] for an edge (u, v), it means there is no alternative path to reach u from v, making (u, v) a bridge. If low[v] > disc[u], it means v cannot reach back to u without (u, v), confirming a bridge.

Company Tags

Wayfair Ernst & Young ARM Dropbox Epic Systems Deloitte HCL Technologies Splunk AMD Pinterest Chewy Western Digital Snowflake PayPal Goldman Sachs Flipkart Johnson & Johnson Red Hat Zynga Ubisoft Freshworks Roche Intel Target Robinhood Google Microsoft Amazon Meta Apple Netflix Adobe