Question: You are given two connected undirected graphs, G1 = (V1, E1) and G2 = (V2, E2), with V1 V2 = , as well as a

You are given two connected undirected graphs, G1 = (V1, E1) and G2 = (V2, E2), with V1 V2 = , as well as a node s V1 and a node t V2. You are also given a set of edges E0 which you are able to build: each edge in E0 has one endpoint in V1 and one endpoint in V2. Thus, building any edge of E0 would connect the two graphs together, and in particular would form paths connecting s and t. You are asked to determine an edge e E0 whose addition to the graphs G1 and G2 would result in the shortest possible (i.e., smallest number of edges) distance between s and t among all the edges in E0 . Give a linear-time algorithm to solve this problem. Just give the algorithm, no proofs are necessary. Recall that linear-time means linear in the size of the input, which for this case is the number of nodes plus the number of edges in the graphs G1 and G2, plus the number of edges in E0 . Hint: you can use BFS as a subroutine to solve this.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!