## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

In graph theory, a bridge (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 bridgeless if it contains no bridges. It is easy to see that this is equivalent to 2-edge-connectivity of each nontrivial component.

A graph with 6 bridges (highlighted in red)

**Bridge-Finding Algorithm
**

An O( | V | + | E | ) algorithm for finding bridges in a connected graph was found by Tarjan in 1974. A distributed version of the algorithm also exists Algorithm: 1. Find a spanning tree of G 2. Create a rooted tree T from the spanning tree 3. Traverse the tree T in preorder and number the nodes. Parent nodes in the tree now have lower numbers than child nodes. 4. For each node from v1 (the leaf nodes of the tree) to 1 (the root node of the tree) do: 1. Compute the number of descendants ND(v) for this node. 2. Compute L(v) and H(v) 3. For each w such that a bridge. : if and H(w) <w + ND(w) then (v,w) is

Definitions: A non-tree edge between v and w is denoted by v í í w. An in-tree edge with v as the parent is denoted by .

wherev is the parent node of w. ND(v) is the number of descendants of v (including itself) in the rooted spanning tree.

L(v) and H(v) 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 LD(v), H(v) and L(v) 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 w, 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 L(w),H(w) are in this set or not to check whether an edge is a bridge.

**Bridge design pattern demo
**

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.

Code:

#include <iostream.h> #include <iomanip.h> #include <string.h> classTimeImp { public: TimeImp(inthr, int min) { hr_ = hr; min_ = min; } virtual void tell() { cout<< "time is " <<setw(2) <<setfill(48) <<hr_ << min_ <<endl; } protected: inthr_, min_; }; classCivilianTimeImp: public TimeImp { public: CivilianTimeImp(inthr, int min, int pm): TimeImp(hr, min) { if (pm) strcpy(whichM_, " PM"); else strcpy(whichM_, " AM"); } /* virtual */ void tell() { cout<< "time is " <<hr_ << ":" << min_ <<whichM_ <<endl; } protected: charwhichM_[4]; }; classZuluTimeImp: public TimeImp { public: ZuluTimeImp(inthr, int min, int zone): TimeImp(hr, min) { if (zone == 5) strcpy(zone_, " Eastern Standard Time");

else if (zone == 6) strcpy(zone_, " Central Standard Time"); } /* virtual */ void tell() { cout<< "time is " <<setw(2) <<setfill(48) <<hr_ << min_ << zone_ << endl; } protected: char zone_[30]; }; class Time { public: Time(){} Time(inthr, int min) { imp_ = new TimeImp(hr, min); } virtual void tell() { imp_->tell(); } protected: TimeImp *imp_; }; classCivilianTime: public Time { public: CivilianTime(inthr, int min, int pm) { imp_ = new CivilianTimeImp(hr, min, pm); } }; classZuluTime: public Time { public: ZuluTime(inthr, int min, int zone) { imp_ = new ZuluTimeImp(hr, min, zone); } }; int main() { Time *times[3]; times[0] = new Time(14, 30); times[1] = new CivilianTime(2, 30, 1); times[2] = new ZuluTime(14, 30, 6); for (int i = 0; i < 3; i++) times[i]->tell(); }

- shortest common superstring1uploaded byMukta Debnath
- Articulation Point using DFS - Algorithmuploaded byтнє Sufi
- BiConnected Component - Algorithmuploaded byтнє Sufi
- Programming Pearlsuploaded byblack Snow
- A Algorithm for the time-dependent shortest path problemuploaded byzun3067302
- Toc Model 2 Mmarkuploaded byAnonymous TNVVbh6fSH
- Linear and quadratic approximationsuploaded byakirank1
- 2011-02-24_an-mincostflowuploaded byttungl
- Time Complexities of Sorting Algorithmsuploaded byVishal Gaur
- Johnson's Algorithmuploaded byladi9510
- Graphuploaded byMuhammed Jehangir Khan
- Graph Theory & Algorithms - M. Ashraf Iqbaluploaded byAbdul Rehman Naeem
- Graphsuploaded byVishal Gaur
- Articulation Point - Algorithmuploaded byтнє Sufi
- Algorithm Graphs with solutionuploaded byтнє Sufi
- Hamiltonian Paths in K-alphabet Grid Graphsuploaded byJournal of Computing
- 28 Slideuploaded byHoàng Vũ
- MFCSuploaded bysurendra332
- Prefer Oppositeuploaded byCamilo Ernesto Pardo Beainy
- Malware detectionuploaded byAlicia Schneider
- 18 Recursive Definitionsuploaded bySpandana Russell
- Get PDFuploaded byShivashis Saha
- srby-lopuploaded byCristiano Ferreira
- Lecture2 Discrete Math Review Handoutuploaded byMonika Yadav
- 10.1.1.52uploaded byBabu Karuppiah
- 5 Computer_Final.pdfuploaded byDeepak Sharma
- Breath First Search - Lecture by Rashid Bin Muhammad, PhDuploaded bypmahesh268
- Structural Web Search Using Graphuploaded byaaarafat_csecu782
- Solveuploaded bySamin Afnan
- 3dquickmold Concept Tutorialsuploaded byAkram Ben Khemis

- Relational Algebra - Intro to DBuploaded byтнє Sufi
- Entity Relationship Model - Intro to DBuploaded byтнє Sufi
- Aaj Himur Biye - Humayun Ahmeduploaded byтнє Sufi
- Elasticity - Micro Economicsuploaded byтнє Sufi
- Macro Production Growthuploaded byтнє Sufi
- Production Cost - Micro Economicsuploaded byтнє Sufi
- Normalization Forms - Intro to Dbuploaded byтнє Sufi
- Articulation Point - Algorithmuploaded byтнє Sufi
- Algorithm Graphs with solutionuploaded byтнє Sufi
- Perfectly Competitive Market - Micro Economicsuploaded byтнє Sufi
- Dynamic Programming - Algorithmuploaded byтнє Sufi
- Shortest Path - Algorithmuploaded byтнє Sufi
- Ai Megh Rodro Chaya - Humayun Ahmeduploaded byтнє Sufi
- Compare and Contrast Writinguploaded byтнє Sufi
- Demand Supply - Micro Economicsuploaded byтнє Sufi
- Graph Introductionuploaded byтнє Sufi
- Business Communication Course Outlineuploaded byтнє Sufi
- Graph Algorithmuploaded byтнє Sufi
- Reccurence - Algorithmuploaded byтнє Sufi
- Greedy Algorithmuploaded byтнє Sufi

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading