badge icon

This article was automatically translated from the original Turkish version.

Article

Dijkstra's Algorithm is a shortest path algorithm used in graph theory, developed in 1956 by Dutch computer scientist Edsger W. Dijkstra. This algorithm is used to find the shortest paths from a specific starting node to all other nodes in a graph. It operates on weighted graphs—where edges have specific weights—and is valid only for graphs that do not contain negative-weight edges.

Working Principle

Dijkstra's Algorithm employs a greedy approach. At each step, it selects the node with the shortest known distance so far and attempts to extend this path to reach other nodes.

1- Initialization:

    2- Selection of the Node with Shortest Distance:

      3- Updating Neighboring Nodes:

        4- Marking as Visited:

          5- Repetition:

            6- Result:



              Dijkstra's Algorithm graph


              Time Complexity

              The time complexity of Dijkstra's Algorithm depends on the data structure used:


              • When using an array: O(V²)
              • When using a priority queue (min-heap): O((V+E)log V)


              Here, V represents the number of vertices and E represents the number of edges.

              Limitations

              • Negative-Weight Edges: Dijkstra's Algorithm does not produce correct results for graphs containing negative-weight edges. For such cases, the Bellman-Ford Algorithm can be used.
              • Directed Graphs: The algorithm works on both directed and undirected graphs.


              Dijkstra's Algorithm is widely used in fields such as route finding, network routing, and geographic information systems.

              Author Information

              Avatar
              AuthorBeyza Nur TürküDecember 25, 2025 at 8:29 AM

              Tags

              Discussions

              No Discussion Added Yet

              Start discussion for "Dijkstra's Algorithm" article

              View Discussions

              Contents

              • Working Principle

                • 1- Initialization:

                • 2- Selection of the Node with Shortest Distance:

                • 3- Updating Neighboring Nodes:

                • 4- Marking as Visited:

                • 5- Repetition:

                • 6- Result:

              • Time Complexity

              • Limitations

              Ask to Küre