Chapter 4: Q6E (page 133)
Question: Prove that for the array prev computed by Dijkstra's algorithm, the edges form a tree.
Short Answer
All the edges form a tree follows this condition if the nodes are connected so there is no cycle.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 4: Q6E (page 133)
Question: Prove that for the array prev computed by Dijkstra's algorithm, the edges form a tree.
All the edges form a tree follows this condition if the nodes are connected so there is no cycle.
All the tools & learning materials you need for study success - in one app.
Get started for free
In cases where there are several different shortest paths between two nodes (and edges have varying length),the most convenient of these paths is often the one with fewest edges. Forinstance, if nodes represent cities and edge lengths represent costs of flying between cities, theremight be many ways to get from cityto city t which all have the same cost. The mostconvenientof these alternatives is the one which involves the fewest stopovers. Accordingly, for a specific starting node S , define
minimum number of edges in a shortest path from S to u .
In the example below, thebestvalues for nodes are , respectively.

Give an efficient algorithm for the following problem.
Input:Graph ; positive edge lengths ; starting node .
Output: The values of should be set for all nodes
You are given a strongly connected directed graph with positive edge weights along with a particular . Give an efficient algorithm for finding shortest paths between all pairs of nodes, with the one restriction that these paths must all pass through .
Give an algorithm for the following task.
Input:An undirected graph ; edge lengths ;an edge .
Output:The length of the shortest cycle containing edge e
Shortest paths are not always unique: sometimes there are two or more different paths with the minimum possible length. Show how to solve the following problem in time.
Input:An undirected graph ;edge lengths ; starting vertex .
Output:A Boolean array for each node u , the entry should be if and only if there is a unique shortest path s to u (Note:)
Give an algorithm that takes as input a directed graph with positive edge lengths, and returns the length of the shortest cycle in the graph (if the graph is acyclic, it should say so). Your algorithm should take time at most .
What do you think about this solution?
We value your feedback to improve our textbook solutions.