how to check efficiently if an edge is a BRIDGE

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
M A Hassan
New poster
Posts: 3
Joined: Tue Nov 02, 2004 12:44 pm

how to check efficiently if an edge is a BRIDGE

Post by M A Hassan »


given the description of a graph how can we check efficiently if a particular edge is a BRIDGE ?
abishek
Experienced poster
Posts: 131
Joined: Mon Dec 15, 2003 5:41 am

Post by abishek »

hint: DFS
M A Hassan
New poster
Posts: 3
Joined: Tue Nov 02, 2004 12:44 pm

Post by M A Hassan »

thank you very much Abishek. but i know about the DFS approach. I also use set union and disjoint set algo for this. but i was looking for something faster ... particularly for implementing Fleury's algorithm.
CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa »

M A Hassan wrote:thank you very much Abishek. but i know about the DFS approach. I also use set union and disjoint set algo for this. but i was looking for something faster ... particularly for implementing Fleury's algorithm.
I don't know how you can search for bridges faster than DFS. Maybe you are looking for the new brach of algorithms called TA (telepathical algorithms)? :lol:

Ciao!!!

Claudio
abishek
Experienced poster
Posts: 131
Joined: Mon Dec 15, 2003 5:41 am

Post by abishek »

Never once tried the fleury's algorithm myself.
always used to merge disjoint cycles.
any body can help?
CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa »

abishek wrote:Never once tried the fleury's algorithm myself.
always used to merge disjoint cycles.
any body can help?
Fleury's algorithm is easy to explain, slow to implement.
You start from a vertex and choose an edge that isn't a bridge for the graph.
Then you travel the edge and delete it from the graph.
From every vertex you visit, if there is an edge that isn't a bridge for the reduced graph you choose it, otherwise you may choose bridges. Travel one and delete it.
When you have deleted all edges and are back to the start vertex you have your euler circuit.

Hope this is clear enough, otherwise let me know

Ciao!!!

Claudio
abishek
Experienced poster
Posts: 131
Joined: Mon Dec 15, 2003 5:41 am

Post by abishek »

I am clear with the fleury algorithm. But how do I implement the idea of checking whether an edge is a bridge or not in the reduced graph? if I use DFS every time, the order will become n^2.
bye
abi
CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa »

abishek wrote:I am clear with the fleury algorithm. But how do I implement the idea of checking whether an edge is a bridge or not in the reduced graph? if I use DFS every time, the order will become n^2.
bye
abi
Indeed, fleury's algorithm is inefficient and I'm not aware of any shortcut that allows to skip (or reduces the complexity of) the DFS search for bridges in the reduced graph.

Ciao!!!

Claudio
backslash null
New poster
Posts: 8
Joined: Tue Nov 11, 2003 11:02 pm

An O(E) approach

Post by backslash null »

Hi,
Here is an O(E) algo to find bridges,
first we define low as follows:

low=min(d,min(low[x] | x is a child of w),min(d[x] | E(u,x) is a back edge);

you can calculate low with a recursive function just like DFS with O(E),
then check for every vertex if its low==d.
and an edge is a bridge if and only if low==d;

*back edge is an edge that is not in DFS tree but it connects a vertex to its ancestors.
abishek
Experienced poster
Posts: 131
Joined: Mon Dec 15, 2003 5:41 am

Post by abishek »

thats only to find it once right?

how do you modify this to implement fleury's algorithm?

bye
abi
Post Reply

Return to “Algorithms”