Bridges in a graph | Algorithms - Computer Science Engineering (CSE) PDF Download

Bridges in a graph

An edge in an undirected connected graph is a bridge iff removing it disconnects the graph. For a disconnected undirected graph, definition is similar, a bridge is an edge removing which increases number of disconnected components.
Like Articulation Points, bridges represent vulnerabilities in a connected network and are useful for designing reliable networks. For example, in a wired computer network, an articulation point indicates the critical computers and a bridge indicates the critical wires or connections.
Following are some example graphs with bridges highlighted with red color:

Bridges in a graph | Algorithms - Computer Science Engineering (CSE)Bridges in a graph | Algorithms - Computer Science Engineering (CSE)Bridges in a graph | Algorithms - Computer Science Engineering (CSE)

How to find all bridges in a given graph?
A simple approach is to one by one remove all edges and see if removal of an edge causes disconnected graph. Following are steps of simple approach for connected graph.

  1. For every edge (u, v), do following
    …..a) Remove (u, v) from graph
    ..…b) See if the graph remains connected (We can either use BFS or DFS)
    …..c) Add (u, v) back to the graph.

Time complexity of above method is O(E * (V + E)) for a graph represented using adjacency list. Can we do better?

A O(V + E) algorithm to find all Bridges

The idea is similar to O(V + E) algorithm for Articulation Points. We do DFS traversal of the given graph. In DFS tree an edge (u, v) (u is parent of v in DFS tree) is bridge if there does not exist any other alternative to reach u or an ancestor of u from subtree rooted with v. As discussed in the previous post, the value low[v] indicates earliest visited vertex reachable from subtree rooted with v. The condition for an edge (u, v) to be a bridge is, “low[v] > disc[u]”.

Following are C++ and Java implementations of above approach:
  • C++
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
  • Java
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
  • Python
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
  • C#
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)
    Bridges in a graph | Algorithms - Computer Science Engineering (CSE)

Output:

  • Bridges in first graph
    3 4
    0 3
  • Bridges in second graph
    2 3
    1 2
    0 1
  • Bridges in third graph
    1 6

Time Complexity: The above function is simple DFS with additional arrays. So time complexity is same as DFS which is O(V + E) for adjacency list representation of graph.

The document Bridges in a graph | Algorithms - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Algorithms.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
81 videos|80 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Bridges in a graph - Algorithms - Computer Science Engineering (CSE)

1. What is a bridge in a graph?
Ans. A bridge in a graph refers to an edge whose removal would increase the number of connected components in the graph. In simple terms, it is an edge that plays a crucial role in maintaining the connectivity of the graph.
2. How can we identify bridges in a graph?
Ans. To identify bridges in a graph, we can make use of various algorithms such as Tarjan's algorithm or the DFS (Depth-First Search) algorithm. These algorithms help in traversing the graph and identifying edges that, when removed, would disconnect the graph or increase the number of connected components.
3. Why are bridges important in graph theory?
Ans. Bridges play a significant role in graph theory as they represent critical connections within a network. By identifying and removing bridges, we can understand the structural integrity of a graph or network. Bridges are commonly used in various fields, including transportation planning, network analysis, and computer science algorithms.
4. Can a graph have multiple bridges?
Ans. Yes, a graph can have multiple bridges. The number of bridges in a graph depends on the connectivity of the graph and the arrangement of its edges. Some graphs may have no bridges, while others may have several. The presence of bridges is determined by the graph's topology and the connections between its vertices.
5. How can the knowledge of bridges in a graph be applied practically?
Ans. The knowledge of bridges in a graph has practical applications in various fields. In transportation planning, identifying bridges can help determine critical road or railway connections that, if disrupted, would affect the overall connectivity. In computer science, bridges are used in algorithms for network routing, network design, and fault tolerance. Additionally, understanding bridges in social networks can assist in identifying influential individuals or groups.
81 videos|80 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Sample Paper

,

Viva Questions

,

pdf

,

ppt

,

Bridges in a graph | Algorithms - Computer Science Engineering (CSE)

,

Bridges in a graph | Algorithms - Computer Science Engineering (CSE)

,

MCQs

,

Objective type Questions

,

Free

,

Previous Year Questions with Solutions

,

video lectures

,

Exam

,

shortcuts and tricks

,

Summary

,

Semester Notes

,

mock tests for examination

,

Bridges in a graph | Algorithms - Computer Science Engineering (CSE)

,

past year papers

,

practice quizzes

,

Important questions

,

Extra Questions

,

study material

;