Question

3. (15 pts) The diameter of a graph is the largest of all shortest-path distances in the graph. In other words, if So(x, y) i

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. Pick a random vertex U
  2. Run a BFS from U to find the farthest vertex V.
  3. If Dist(U,V) is better than the best diameter found then update it, else exit.
  4. Assign V to U and go back to step 2

In this above algorithm you will be looping in a nested for loop as fixing one node and then searching through next all connected nodes, so it will take O(V2)

Add a comment
Know the answer?
Add Answer to:
3. (15 pts) The diameter of a graph is the largest of all shortest-path distances in the graph. I...
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
  • 2. Let G be an undirected graph. For every u,vE V(G), let dc(u,v) be the length of the shoertest ...

    2. Let G be an undirected graph. For every u,vE V(G), let dc(u,v) be the length of the shoertest path from u to v. The diameter of G is he maximum distance bet In other words: max (de(u, v) u,vEV(G) the running time of your algorithm 2. Let G be an undirected graph. For every u,vE V(G), let dc(u,v) be the length of the shoertest path from u to v. The diameter of G is he maximum distance bet In...

  • Consider the width search algorithm from a start node s. The diameter of an undirected, contiguous...

    Consider the width search algorithm from a start node s. The diameter of an undirected, contiguous Graph G = (V, E) is defined as the maximum over all node pairs v, w ∈ V of the length of the shortest path from v to w. We assume that each edge has the length of 1. Specify an extension of the width search algorithm in pseudo code that has the diameter of an undirected graph G = (V, E). First explain...

  • a. (15 marks) i (7 marks) Consider the weighted directed graph below. Carry out the steps...

    a. (15 marks) i (7 marks) Consider the weighted directed graph below. Carry out the steps of Dijkstra's shortest path algorithm as covered in lectures, starting at vertex S. Consequently give the shortest path from S to vertex T and its length 6 A 2 3 4 S T F ii (2 marks) For a graph G = (V, E), what is the worst-case time complexity of the version of Dijkstra's shortest path algorithm examined in lectures? (Your answer should...

  • Problem 6. (Weighted Graph Reduction) Your friend has written an algorithm which solves the all pairs shortest path pr...

    Problem 6. (Weighted Graph Reduction) Your friend has written an algorithm which solves the all pairs shortest path problem for unweighted undirected graphs. The cost of a path in this setting is the number of edges in the path. The algorithm UNWEIGHTEDAPSP takes the following input and output: UNWEİGHTEDA PSP Input: An unweighted undirected graph G Output: The costs of the shortest paths between each pair of vertices fu, v) For example, consider the following graph G. The output of...

  • Q1: Here we consider finding the length of the shortest path between all pairs of nodes...

    Q1: Here we consider finding the length of the shortest path between all pairs of nodes in an undirected, weighted graph G. For simplicity, assume that the n nodes are labeled 1; 2; : : : ; n, that the weight wij of any edge e = (i; j) is positive and that there is an edge between every pair of nodes. In this question, the goal is to solve this via dynamic programming. Note that the algorithm you will...

  • can you please solve this CORRECTLY? Exercise 4 - Shortest path (25 pts) Using Dijkstra's algorithm,...

    can you please solve this CORRECTLY? Exercise 4 - Shortest path (25 pts) Using Dijkstra's algorithm, find the shortest path from A to E in the following weighted graph: a- Once done, indicate the sequence (min distance, previous node) for nodes D and E. (15pts) b- Below is a high-level code for Dijkstra's algorithm. The variables used in the code are self-explanatory. Clearly explain why its running time (when we use a min-heap to store the values min distance of...

  • 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...

  • 9. In the graph below (A) Determine the shortest path from a to ALL other nodes using Dijkstra's ...

     9. In the graph below (A) Determine the shortest path from a to ALL other nodes using Dijkstra's Shortest Path Algorithm, The answers must be in the following form: For each node, give the shortest path from a to that node (that is, list the nodes in the path). Also for each path give the length of the path. (B) ON THIS SHEET OF PAPER SHOWING A TRACE OF DIJKSTRA'S ALGORITHM ON THE GRAPH BELOW AS IDID IN CLASS FOR FULL CREDIT YOU MUST LABEL...

  • please answer one of the two 1. (25) [Single-source shortest-path: algorithm tracing] Show the tracing of...

    please answer one of the two 1. (25) [Single-source shortest-path: algorithm tracing] Show the tracing of Dijkstra's shortest path search algorithm on the weighted directed graph shown below. Do the tracing it twice, first starting with the nodes and, second, starting with the node z. For each tracing, each time the shortest path to a new node is determined, show the graph with the shortest path to the node clearly marked and show inside the node the shortest distance to...

  • Problem 1: Shortest Path-ish Suppose that you want to get from vertex s to vertex t in an...

    Problem 1: Shortest Path-ish Suppose that you want to get from vertex s to vertex t in an unweighted graph G = (V, E), but you would like to stop by vertex u if it is possible to do so without increasing the length of your path by more than a factor of a. Describe an efficient algorithm that would determine an optimal s-t path given your preference for stopping at u along the way if doing so is not prohibitively costly....

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