21. Critical Connections in a Network

Finding the Bridges

An edge is a bridge removing it increases the number of components in a graph If there are no backedge from a node to its parent or ancestor then the edge is a bridge.

There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between servers ai and bi. Any server can reach other servers directly or indirectly through the network.

A critical connection is a connection that, if removed, will make some servers unable to reach some other server.

Return all critical connections in the network in any order.

Example 1:

Solution:

Tarjan's algorithm

Time Complexity: O(V + E)

Last updated

Was this helpful?