Algorithms And Data Structures Codexery

Dijkstra's algorithm

Algorithm for shortest paths in weighted graphs.

Dijkstra's algorithm

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a weighted graph, such as a road network. It was conceived by computer scientist Edsger W. The algorithm finds the shortest path from a given source node to every other node and is a cornerstone of graph theory and network routing.

field
Computer science
known_for
Dijkstra's algorithm for shortest paths

Lore & Background

Dijkstra designed the algorithm in about twenty minutes while sitting on a café terrace in Amsterdam with his fiancée. He was thinking about the shortest path problem and created the algorithm without pencil and paper, which he later said forced him to avoid unnecessary complexities. The algorithm was originally implemented for the ARMAC computer to demonstrate its capabilities using a simplified transportation map of 64 cities in the Netherlands. The original algorithm ran in Θ(|V|²) time, where |V| is the number of nodes. Later, Fredman and Tarjan proposed a Fibonacci heap priority queue to optimize the running time to Θ(|E| + |V| log |V|), which is asymptotically the fastest known for arbitrary directed graphs with unbounded non-negative weights. The algorithm is commonly used on graphs with positive integer or real edge weights and can be generalized to partially ordered weights with monotonically non-decreasing labels. It is employed in network routing protocols such as IS-IS and OSPF, and as a subroutine in algorithms like Johnson's algorithm.

Reader's Guide

Dijkstra's algorithm is significant as one of the most fundamental and widely used algorithms in computer science. It provides an efficient method for solving the single-source shortest path problem on weighted graphs with non-negative edges. The algorithm's influence extends across many fields, including artificial intelligence, where it is formulated as uniform cost search and as an instance of best-first search. Its practical applications include network routing protocols (IS-IS and OSPF), GPS navigation systems, and as a building block for more complex algorithms. The algorithm's elegance and efficiency have made it a standard topic in computer science education and a cornerstone of Dijkstra's fame. Its legacy includes ongoing optimizations, such as contraction hierarchies, which can be up to seven orders of magnitude faster when preprocessing is allowed.

Did You Know?

Frequently Asked Questions

What are Dijkstra's algorithm's powers and role?

Its core ability is to explore a weighted graph step by step, always expanding the closest unvisited node next, until every reachable node has its minimum distance locked in. This makes it a foundational tool for network routing and pathfinding in computer science.

How does Dijkstra's algorithm's story end?

The process concludes once every node in the graph has been permanently assigned its shortest-path distance from the source. At that point the algorithm halts, having produced a complete distance table for the entire network.

Why is Dijkstra's algorithm important?

It became a cornerstone of graph theory because it offers a reliable, efficient way to solve single-source shortest-path problems in graphs with non-negative edge weights. Its logic underpins many real-world systems, from GPS navigation to internet packet routing.

More in Algorithms And Data Structures 1-24

Elsewhere in the Algorithms And Data Structures universe

Spotted an error? Know more?

This is a living reference — every entry is fact-audited, and reader corrections feed straight into our audit queue. Suggest an edit · See this site's audit record

Comments

Loading…
Open in the interactive codex →