Bridge - Algorithm
Bridge - Algorithm
In graph theory, a à (also known as a cut-edge or cut arc or an isthmus) is an edge whose
deletion increases the number of connected components. Equivalently, an edge is a bridge if and
only if it is not contained in any cycle.
A graph is said to be à if it contains no bridges. It is easy to see that this is equivalent to
2-edge-connectivity of each nontrivial component.
c
An ½( | | + | | ) algorithm for finding bridges in a connected graph was found by Tarjan in
1974. A distributed version of the algorithm also exists
Algorithm:
- (3) is the number of descendants of v (including itself) in the rooted spanning tree.
D(3) and (3) are the labels of the nodes with lowest and highest preorder label respectively
reachable from v by travelling in the subtree rooted at v, along with at most one non-tree edge.
This algorithm works because D (3), (3) and D(3) can all be computed for a node v provided
we know their values on all in-tree descendants of v. Also, if and only if the edge is a
bridge, then it is clear that in the subtree rooted at d, it must be impossible to reach any node that
is not a descendant of w. This is easy to check because the subtree rooted at w (that is, all
descendants of w) consists of the nodes so we can
simply check if D(d),(d) are in this set or not to check whether an edge is a bridge.
c
The motivation is to decouple the Time interface from the Time implementation, while still allowing the
abstraction and the realization to each be modelled with their own inheritance hierarchy. The
implementation classes below are straight-forward. The interface classes are a little more subtle.
Routinely, a Bridge pattern interface hierarchy ͞hasa͟ implementation class. Here the interface base
class ͞hasa͟ a pointer to the implementation base class, and each class in the interface hierarchy is
responsible for populating the base class pointer with the correct concrete implementation class. Then
all requests from the client are simply delegated by the interface class to the encapsulated
implementation class.
è
w
w
w
!
!
"#
$ %&
(" )!*)!
(" )!+)!
,-
-,
!
!!! " )
" ).%/
(1 !3
4
!
$1 5
"
8
-