Question

NAME . You are given a strongly connected directed graph G (V, E) with positive edge weights along with a particular node vo E V. Give an efficient algorithm for finding shortest paths between all pairs of nodes, with the one restriction that these paths must all pass through v (8 points)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The shortest path between two nodes u and v that passes through v0 must be the shortest path from u to v0 and the shortest path from v0 to v. We can easily compute the latter using Dijkstra’s algorithm in O ((n + m) lg n) time. To compute the former, observe that we want to compute the shortest paths from every vertex to v0. This is exactly the opposite of the shortest path problem, so we can solve it easily by first reversing the graph and then running Dijkstra’s algorithm to compute the shortest paths from v0 to each vertex in GR. Reversing the graph takes linear time (as shown in the previous assignment) so this also takes O ((n + m) lg n) time. Storing all of the shortest path lengths would require O (n 2 ) time and space, so we simply keep these two arrays of shortest paths. Using these we can answer a shortest path length query from u to v by adding the shortest path length from u to v0 (in the second array we created) and the shorteste path length from v0 to v (using the first array).

Add a comment
Know the answer?
Add Answer to:
NAME . You are given a strongly connected directed graph G (V, E) with positive edge...
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
  • Given a directed graph with positive edge lengths and a specified vertex v in the graph,...

    Given a directed graph with positive edge lengths and a specified vertex v in the graph, the "all-pairs" v-constrained shortest path problem" is the problem of computing for each pair of vertices i and j the shortest path from i to j that goes through the vertex v. If no such path exists, the answer is . Describe an algorithm that takes a graph G= (V; E) and vertex v as input parameters and computes values L(i; j) that represent...

  • 10. You are given a directed graph G(V, E) where every vertex vi E V is...

    10. You are given a directed graph G(V, E) where every vertex vi E V is associated with a weight wi> 0. The length of a path is the sum of weights of all vertices along this path. Given s,t e V, suggest an O((n+ m) log n) time algorithm for finding the shortest path m s toO As usual, n = IVI and m = IEI.

  • Problem 1: Given a graph G (V,E) a subset U S V of nodes is called...

    Problem 1: Given a graph G (V,E) a subset U S V of nodes is called a node cover if each edge in E is adjacent to at least one node in U. Given a graph, we do not know how to find the minimum node cover in an efficient manner. But if we restriet G to be a tree, then it is possible. Give a greedy algorithm that finds the minimum node cover for a tree. Analyze its correctness...

  • Give an efficient algorithm that takes a directed graph G = (V, E) and two vertices...

    Give an efficient algorithm that takes a directed graph G = (V, E) and two vertices u, v E V, and determines if there are at least two edge-disjoint paths in G from u to v. i.e., your algorithm should determine whether there are at least two paths from u to v in G that have no edges in common. Argue your algorithm's correctness and analyze its time complexity.

  • Let G = (V, E, W) be a connected weighted graph where each edge e has...

    Let G = (V, E, W) be a connected weighted graph where each edge e has an associated non-negative weight w(e). We call a subset of edges F subset of E unseparating if the graph G' = (V, E\F) is connected. This means that if you remove all of the edges F from the original edge set, this new graph is still connected. For a set of edges E' subset of E the weight of the set is just the...

  • Shortest paths Consider a directed graph with vertices fa, b, c, d, e, f and adjacency...

    Shortest paths Consider a directed graph with vertices fa, b, c, d, e, f and adjacency list representation belovw (with edge weights in parentheses): a: b(4), f(2) e: a(6), b(3), d(7) d: a(6), e(2) e: d(5) f: d(2), e(3) (i) Find three shortest paths from c to e. (ii) Which of these paths could have been found by Dijkstra's shortest path algorithm? (Give a convincing explanation by referring to the main steps of the algorithm.)

  • You are given an unweighted DAG (Directed Acyclic Graph) G, along with a start node s...

    You are given an unweighted DAG (Directed Acyclic Graph) G, along with a start node s and a target node t. Design a linear time (i.e., runtime O(IV+ EI)) dynamic programming algorithm for computing the number of all paths (not necessarily shortest) from s to t.

  • Consider the problem of finding the shortest paths in a weighted directed graph using Dijkstra's algorithm.

    Consider the problem of finding the shortest paths in a weighted directed graph using Dijkstra's algorithm. Denote the set of vertices as V, the number of vertices as |V|, the set of edges as E, and the number of edges as |E|. Answer the following questions.Below is a pseudo-code of the algorithm that computes the length c[v] of the shortest path from the start node s to each node v. Answer code to fill in the blank _______ .

  • Problem 5. (12 marks) Connectivity in undirected graphs vs. directed graphs. a. (8 marks) Prove that...

    Problem 5. (12 marks) Connectivity in undirected graphs vs. directed graphs. a. (8 marks) Prove that in any connected undirected graph G- (V, E) with VI > 2, there are at least two vertices u, u є V whose removal (along with all the edges that touch them) leaves G still connected. Propose an efficient algorithm to find two such vertices. (Hint: The algorithm should be based on the proof or the proof should be based on the algorithm.) b....

  • ALGORITHM DESIGN Given a connected weighted graph, give a scheme to find the farthest node from...

    ALGORITHM DESIGN Given a connected weighted graph, give a scheme to find the farthest node from a given source node. Note that you do not have to start from scratch, but use a known standard algorithm. Hint: Make sure use of a known algorithm for finding the shortest paths.

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