Inferensys

Glossary

Dijkstra's Algorithm

Dijkstra's algorithm is a foundational graph search algorithm that computes the shortest paths from a single source node to all other nodes in a weighted graph with non-negative edge weights.
Engineer reviewing vector database search results on laptop, embeddings visualization on screen, home office coding session.
MOTION PLANNING AND TRAJECTORY OPTIMIZATION

What is Dijkstra's Algorithm?

A foundational graph search algorithm for finding optimal paths in weighted networks, central to robotic navigation and network routing.

Dijkstra's algorithm is a graph search algorithm that computes the shortest paths from a single source node to all other nodes in a weighted graph with non-negative edge weights. It operates by iteratively expanding the frontier from the source, always selecting the node with the smallest known distance, a strategy known as a greedy algorithm. This guarantees optimality for graphs without negative cycles, making it a cornerstone for motion planning in robotics and network routing protocols like OSPF.

In embodied intelligence systems, Dijkstra's algorithm is often applied to discretized representations of an environment, such as a grid or graph of waypoints, to find the minimum-cost trajectory for a robot. While powerful for global planning on static maps, its exhaustive search can be computationally intensive for large state spaces, leading to the use of heuristic-guided variants like A search*. Its core principle of optimal substructure—where the shortest path to a node contains the shortest paths to intermediate nodes—is fundamental to many subsequent trajectory optimization and dynamic programming methods.

FOUNDATIONAL ALGORITHM

Key Characteristics of Dijkstra's Algorithm

Dijkstra's algorithm is a foundational graph search algorithm for finding the shortest paths from a single source node to all other nodes in a weighted graph with non-negative edge weights. Its core characteristics define its behavior, guarantees, and limitations within motion planning and broader computational contexts.

01

Single-Source Shortest Paths

Dijkstra's algorithm solves the Single-Source Shortest Path (SSSP) problem. From a designated source node, it computes the shortest path distance (and can reconstruct the path) to every other reachable node in the graph. This is in contrast to algorithms like Floyd-Warshall, which compute all-pairs shortest paths, or A*, which finds a path to a single goal. The algorithm maintains a tentative distance for each node, which it iteratively finalizes in order of increasing distance from the source.

02

Greedy Optimality & Non-Negative Weights

The algorithm operates on a greedy principle. At each step, it selects the unvisited node with the smallest known tentative distance and finalizes it, declaring that distance as optimal. This greedy choice is guaranteed to be correct only if all edge weights are non-negative. A negative weight could create a cycle that reduces the total path distance, violating the assumption that a finalized distance is minimal. For graphs with negative weights, the Bellman-Ford algorithm must be used instead.

03

Computational Complexity

The time complexity of Dijkstra's algorithm depends heavily on the data structure used for the priority queue that selects the next node to visit.

  • Simple Array: O(|V|²) - Suitable for dense graphs.
  • Binary Heap Priority Queue: O((|E| + |V|) log |V|) - The standard efficient implementation for sparse graphs common in robotics.
  • Fibonacci Heap: O(|E| + |V| log |V|) - Asymptotically better for very large, sparse graphs.

Here, |V| is the number of vertices (nodes) and |E| is the number of edges.

04

Graph Abstraction for Planning

In motion planning, the robot's configuration space (C-space) is discretized into a graph for Dijkstra's algorithm to search.

  • Nodes represent discrete robot states or configurations.
  • Edges represent feasible transitions between states (e.g., small motions).
  • Edge Weights encode the cost of a transition, such as distance, time, energy consumption, or a penalty for proximity to obstacles. This transforms the continuous planning problem into a discrete graph search, where the output is the minimum-cost sequence of states from start to goal.
05

Comparison with A* Search

While both find shortest paths, key differences are crucial for performance:

  • Dijkstra: Explores uniformly in all directions from the source. It finds optimal paths to all nodes.
  • A*: Uses a heuristic function (e.g., Euclidean distance to goal) to guide exploration preferentially toward the goal. It is typically faster for single-goal queries but requires an admissible heuristic (never overestimates cost) to guarantee optimality. Dijkstra is equivalent to A* with a heuristic function of zero. In robotics, A* is often preferred for point-to-point planning, while Dijkstra's property of exploring the entire reachable space can be useful for multi-goal planning or building distance maps.
06

Foundational Role in Advanced Planners

Dijkstra's algorithm is not just a standalone planner; it is a core subroutine in more advanced robotic systems:

  • Distance Transform: Used to compute a gradient or cost-to-go map from goal regions, which can guide local planners or sampling-based algorithms.
  • Probabilistic Roadmap (PRM): Once a roadmap graph is constructed, Dijkstra's algorithm is used to find the shortest path within it.
  • Dynamic Window Approach (DWA): The global path, often computed by Dijkstra or A*, provides the objective for the local, reactive planner. Its guarantee of global optimality (within the discretized graph) makes it a trusted component for generating reference paths in hierarchical planning architectures.
PATHFINDING ALGORITHM COMPARISON

Dijkstra's Algorithm vs. Other Search Methods

A technical comparison of Dijkstra's Algorithm against other fundamental graph search and pathfinding methods used in robotics motion planning.

Feature / MetricDijkstra's AlgorithmA* SearchBreadth-First Search (BFS)Greedy Best-First Search

Primary Objective

Find shortest paths from a single source to all nodes

Find shortest path from a single source to a single goal

Find any path, exploring uniformly in all directions

Find a path quickly, not necessarily the shortest

Graph Type

Weighted graph (non-negative edges)

Weighted graph (non-negative edges)

Unweighted graph

Weighted or unweighted graph

Optimality Guarantee

Completeness Guarantee

Heuristic Use

Time Complexity (Worst-Case)

O(|E| + |V| log |V|) with priority queue

O(|E|) but depends heavily on heuristic quality

O(|V| + |E|)

O(|V| + |E|)

Space Complexity

O(|V|)

O(|V|)

O(|V|)

O(|V|)

Typical Data Structure

Priority Queue (Min-Heap)

Priority Queue (Min-Heap)

Queue (FIFO)

Priority Queue (Min-Heap)

Best For (Robotics Context)

Computing all possible shortest paths for global costmaps

Efficient, optimal point-to-point navigation with a good heuristic

Exploring an unknown, unweighted grid to find any reachable goal

Fast, approximate planning where optimality is secondary to speed

DIJKSTRA'S ALGORITHM

Frequently Asked Questions

Dijkstra's algorithm is a foundational graph search method for finding shortest paths, with critical applications in robotic motion planning, network routing, and logistics. These FAQs address its core mechanics, limitations, and role in modern autonomous systems.

Dijkstra's algorithm is a graph search algorithm that finds the shortest paths from a single source node to all other nodes in a weighted graph with non-negative edge weights. It works by iteratively exploring the graph, always expanding the node with the smallest known distance from the source. It maintains two sets: a settled set of nodes whose shortest distance is finalized, and a priority queue (often a min-heap) of unsettled nodes. The algorithm greedily selects the node with the minimum tentative distance from the queue, adds it to the settled set, and relaxes its outgoing edges—updating the distances to its neighbors if a cheaper path is found through the current node. This process repeats until the queue is empty, guaranteeing optimal shortest paths for all reachable nodes.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.