Wk 7/8 : SSSP, BF, Dijkstra, APSP, FW, Trans. Closure Flashcards
Can a shortest path have cycles? Why not?
If you find an SSSP with a cycle, and remove it, you still have a source to definition and the total weight is less.
How does the single-source-shortest-path problem relate to its cousins? (what are its cousins?)
single-destination (SSSP in opposite direction this would be a column in the matrix)
single-pair (this is a single entry in the matrix, it is already solved when SSSP is run, and its not any faster)
all-pairs shortest path (this is finding every value in the matrix, in other words all the rows and all the columns, therefore also all the pairs/points as well) You don’t need to run SSSP from each vertex to find this, we can do it quicker.
single source finds a row in the matrix.
What is the optimal sub-structure of a shortest path mean?
Every sub-path of a SSSP is also a SSSP. This is what connects this to dynamic programming and the greedy method.
What is the relationship between negative weight cycles and the shortest path algorithms?
shortest path is not defined for a graph that has negative weight cycles, because any shortest path would continually go round and round that cycle and get -INF weight
What is the main difference between Dijkstra and Bellman-Ford with regard to assumptions?
Bellman-Ford can handle negative weight edges but is slower. Dijkstra takes advantage of the assumption that if there are no negative edge weights and runs faster than Bellman-Ford.
How do we track the actual shortest path found by the algorithm?
With predecessor pointers and Shortest-Path trees.
What is the general format for all the algorithms in this chapter? (BF and Dijk)
Initialize the d values and pointers of every node, then repeatedly “relax” the deges until we have the shortest path
How does Bellman-Ford return whether or not there are negative weight cycles in the graph?
After it runs to get the shortest path, it runs one more time and if the weights decrease again, then we know there’s a negative cycle somewhere.
What is the main data structure of Dijkstra’s algorithm? Why?
Priority Queue…
[INSERT]
How does Dijkstra use the assumption of no negative edge weights in its advantage?
[INSERT]
What are the similarities between Dijkstra and Primm? What are the differences?
[INSERT]
Why is Dijkstra considered to be a greedy algorithm?
Each time through its loop it pulls the current lowest value vertex from the priority queue to add to the set S which is the growing SSSP.
Prove that the u that comes off the priority queue in Dijkstra is in fact the SP….
[INSERT]
How is Dijkstra similar to both Primm and BFS?
Single source shortest path algorithms (Dijkstra) are just BFS with different data structures. Dijkstra uses a priority queue. BFS only used a standard queue. Primm used priority queue as well.
How many times do we have to run the EXTEND SHORTEST PATHS within the SLOW-ALL-PAIRS SHORTEST PATHS algorithm? How about for the FAST?
We have to do it n-1 times. Once we hit the nth time, the matrix values don’t change. Essentially every edge and every path has been looked at. For the fast, it’s CLG(lg n) because that’s how many times it takes until we’re bigger than n. Book says that all L^m = L^n-1 for all m >= n-1