Download presentation
Presentation is loading. Please wait.
Published byAlyson Monica Thomas Modified over 9 years ago
1
7 Finding Bridge in a Graph
2
What is a bridge ? A C D B F G E
3
Why we need to find bridge(s)? A graph with a lot of bridge is weakly connected.
4
Articulation Point A C D B E We will not cover how to find articulation point(s) now, but it is similar to bridge’s
5
Trivial Algorithm
6
We can find bridge(s) in a graph using modified DFS algorithm.
7
AC D B F G E A B D E C G F A E C G
8
We want to gather more information from DFS, so we add ordering number and parent’s id.
9
AC D B F G E A B D E C G F A E C G NodeABCDEFG Order1234567 Parent-ABCCEF 1/- 2/A 3/B 4/C 5/C 6/E 7/F 3 7 1 5 A is C’s ancestor, because the order number is smaller C is A’s descendant, because the order number is bigger
10
Notice that whenever we find an ancestor node, we actually found a cycle. We can count the cycle’s size by tracing up, using parent’s info that we stored. A B D E C G F A E C G NodeABCDEFG Order1234567 Parent-ABCCEF 1/- 2/A 3/B 4/C 5/C 6/E 7/F 3 7 1 5
11
Observe: Cycle AC D B F G E
12
DFS
13
NodeABCDEFG Order1234567 Parent-ABCCEF Low#1114555 Initially, low is set to order number When found an ancestor node, return its low # A node always choose smaller low # of its children A B D E C G F A E C G 1/-/1 2/A/2 3/B/3 4/C/4 5/C/5 6/E/6 7/F7 3 7 1 5 3/B/1 2/A/1 7/F/5 6/E/5
14
Every pink and red edges on DFS Tree corresponds to an edge on original graph A B DE C G F A E C G 1/-/1 2/A/1 3/B/1 4/C/4 5/C/5 6/E/5 7/F/5 3 7 1 5 AC D B F G E There are 3 nodes which has same order and pre number Corresponding edges of these nodes are bridges Root doesn’t have corresponding edge So we only have 2 bridges in this graph
15
Running Time
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.