Lecture 16: Dijkstra
Why Stack Overflow recommends it
Stack Overflow users link it when explaining edge relaxation in Dijkstra's algorithm and when asking about the linear shortest-path algorithm for DAGs.
Recommended by 1 people across 1 different months, 2013 to 2024.
What it is
A full MIT 6.006 lecture in which Srini Devadas covers shortest-path algorithms: edge relaxation, shortest paths in DAGs via topological order, and Dijkstra's algorithm. It is a recorded university lecture from MIT OpenCourseWare, Fall 2011.
What people said
Recommends user825628 · 2022-03 · Stack Overflow · on “Relaxation of an edge in Dijkstra's algorithm”
Take a look at [this video] Time: 28:30. Funny thing is that the shortest paths are the ones that are under TENSION. To me this is the exact opposite of RELAX. Oh well.
Cites Cisplatin · 2013-09 · Stack Overflow · on “Why doesn't the linear shortest path algorithm work for non-directed cyclic graphs?”
I have the basic linear shortest path algorithm implemented in Python. According to various sites I've come across, this only works for directed acyclic graphs, including this [LINK] , this [LINK] , and this [this video] . However, I don't see why this is the case. I've even tested the algorithm against graphs with cycles and un-directed edges, and it worked fine. So the question is, why doesn't the linear shortest path algorithm work for non-directed cyclic graphs? Side question, what is the name of this algorithm? For reference, here is the code I wrote for the algorithm: def shortestPath(start, end, graph): # First, topologically sort the graph, to determine which order to traverse it in sorte
Cites Patrik Fuhrmann · 2013-11 · Stack Overflow · on “Dijkstra algorithm with min-priority queue”
You should use priority queue where the vertex with the shortest distance from the starting vertex will get the highest priority. Initially, all vertices will have the shortest distance of infinity and the starting vertex will have the shortest distance 0. Start by inserting of all vertices (with its edges ) from the graph inside the PQ . Remove vertex from the PQ and explore all its edges . Compare the shortest distances with all adjacent vertices and if any distance is less than the shortest distance on the current vertex , update adjacent vertex shortest distance inside the PQ . Continue while PQ is not empty. Vertices which got no edges will finish with the shortest distance of infinity
Cites Y.T. · 2019-11 · Stack Overflow · on “Find shortest path in graph algorithm”
I have just seen this video: [this video] It talks about an algorithm that finds the shortest distance between a source and a given vertex in a DAG: 1.Sort the graph in topological order and express the graph in its linear form 2.Initialize all of the vertex to infinity except the source, which is initialized to 0 3.Iterate from the source to the rightmost vertex. For every vertex u, update the distance of all of its neighbor v to min((distance between source and v), (distance between source and u) + (distance between u and v)) At about 22:00, the professor said that this algorithm works for negative edges but the graph cannot contain cycle, but i think the algorithm works for graphs that contain
Cites Alexey · 2024-03 · Stack Overflow · on “Relaxation of an edge in Dijkstra's algorithm”
Here is my interpretation of the accepted answer [LINK] , as well as of the demonstration video [this video] linked from another answer [LINK] . Imagine that the graph edges are ropes of given lengths. To get the shortest path distances from the source node to all the other nodes, as well as the shortest paths themselves, it is enough to hold the source node and let the other ones suspend from it vertically on the ropes. This is a physical solution. To get an algorithmic solution, however, the physical laws need to be explicitly tested and enforced. Let now the graph edges be elastically stretchable, with given lengths at rest. Pin the source node fixed and pin all the other nodes strictly vertic