Dijkstra’s algorithm Flashcards
What is Dijkstra’s algorithm?
It’s a graph algorithm that find the fastest solution
How does Dijkstra’s algorithm works?
Dijkstra’s algorithm:
1. Find the “cheapest” node. This is the node you can get to in the least amount of time.
2. Update the costs of the neighbors of this node.
3. Repeat until you’ve done this for every node in the graph.
4. Calculate the final path.
What is weight in Dijkstra’s algorithm?
It’s the number that associated with the edge
A graph with weights is called a weighted graph. A graph without weights is called an unweighted graph.
How to calculate path in graphs?
To calculate the shortest path in an unweighted graph, use breadth-first search. To calculate the shortest path in a weighted graph, use Dijkstra’s algorithm.
Can we use negative weight edges with Dijkstra’s algorithm?
No