Question

Problem 5: Aging Infrastructure [20 points Around the United States, subway systems that were built decades ago are ages. New
(b) 10 points Describe the most efficient algorithm you can to find all the critical subway segments in the citys subway sys
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. In given graph Cities are vertices and subway are edges.Graph is undirected as we can go A to B and can also come back. Unweighted graph.

2. Even after removing a edge if a graph is connected then the edge is not critical otherwise it is critical edge.

Tarjan algorithm for finding bridge . This algorithm mainly maintains two array dis[ ] and low[ ]. dis array mainly contain number of dfs call we needed to get to this node and low contains smallest number of call to reach a vertex which is connected to our vertices . If u,v is connected and u is parent of vand low[v]>dis[u] then u,v is a bridge.

int dfs(int i)

{

static int time=0;

int cou_o_children=0; // count of children

vis[i]=true; dis[u]=low[u]=++time; // make current node as visited and intialise time to get to that node and minimum time to get to that node

for(auto k=v1[i].begin();k!=v1[i].end();k++)

{

if(vis[*k]==0)

{

par[*k]=i; dfs(*k);

low[i] = min(low[i], low[*k]); // check subtree rooted at *k has connection with one of ancestor of i

if (low[*k] > disc[i]) // it means *k and i is critical subway.

}

else if (*k != parent[i]) // update low value for i

low[i] = min(low[i], disc[*k]);

}

}

3. Critical edge are also called bridge edge . Time complexity of most efficient algorithm is O(V+E) using adjacency lists. Basically in this algorithm we are doing dfs . In DFS tree an edge (u, v) is bridge if there is no way to reach u or an ancestor of u from subtree rooted with v if we remove edge between (u,v).

Add a comment
Know the answer?
Add Answer to:
Problem 5: Aging Infrastructure [20 points Around the United States, subway systems that were built decades...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT