Overview: The formal definition describes how to compute the shortest path between two vertices in a graph using a systematic approach. It formalizes the idea of Dijkstra's algorithm, where each vertex is processed step-by-step, and distances are updated to find the shortest path from a starting vertex to a terminal vertex.
Graph Representation:
The graph consists of a set of vertices (π) and edges (πΈ). Each edge has a weight that represents the distance between two connected vertices. These distances are stored in a matrix (π), where the value at position
The Shortest Path Problem: Given: A starting vertex (s). A terminal vertex (e). The task is to find the shortest path from (s) to (e), which is the sequence of vertices and edges with the smallest total weight. Components of the Approach: Position-Dependent Sequence ( Ξ¨ Ξ¨): This structure stores information about each vertex, including its current shortest distance from the starting vertex and whether it has been fully processed. Each vertex has three associated values: π£ v: the vertex itself. π p: the shortest known distance to π£ v. π ΞΆ: a marker indicating whether the vertex has been processed. Algorithm Steps: Initialization (Algorithm-I):
Start by initializing the distance of all vertices to infinity ( β β) except the starting vertex ( π s), which is set to 0. Mark all vertices as unprocessed ( π
0 ΞΆ=0). This step prepares the structure ( Ξ¨ Ξ¨) to hold the initial state of the graph. Selecting the Next Vertex (Algorithm-II):
Among all unprocessed vertices, find the one with the smallest distance from the starting vertex ( π p). If this vertex is the terminal vertex ( π e), the algorithm terminates because the shortest path has been determined. Otherwise, mark the selected vertex as processed ( π
1 ΞΆ=1). Updating Distances (Algorithm-III):
For the selected vertex, examine all its neighboring vertices. Calculate the potential new distance to each neighbor as the sum of the selected vertexβs current distance ( π p) and the weight of the edge connecting the two vertices ( π π π m ij β ). If this new distance is smaller than the previously known distance to the neighbor, update the neighbor's distance in the structure ( Ξ¨ Ξ¨). Key Details: The algorithm ensures that each vertexβs shortest path is finalized before moving to the next vertex. This is why the vertex with the smallest distance is always selected. Once a vertex is processed, its distance value ( π p) is guaranteed to be the shortest possible distance from the starting vertex ( π s). Termination: The process continues until either: The terminal vertex ( π e) is reached, meaning the shortest path has been found. All vertices are processed, ensuring that every vertexβs shortest path from π s is calculated. Why This Works: The algorithm's logic relies on iteratively exploring the shortest known paths to unprocessed vertices and updating neighbors' distances if a shorter path is discovered. This guarantees that the shortest path to any vertex is finalized before moving forward, which is the foundation of Dijkstra's algorithm.
In summary, this formal definition is a precise mathematical representation of Dijkstraβs algorithm, broken into three key steps: initializing distances, selecting the next vertex to process, and updating the distances of its neighbors. It carefully tracks the state of each vertex using a sequence ( Ξ¨ Ξ¨), ensuring that the algorithm proceeds in an organized and efficient manner to find the shortest path.
Let
If vertex
- Let
$$\Psi$$ be a position-dependent sequence structure that stores the vertices of$$V$$ in a lesser position order calculated from the initial vertex$$s$$ ; such that$$\psi = \{v, p, \zeta\}$$ . - Algorithm-I (Initialize the position-dependent sequence with the distances from the initial vertex
$$s$$ ): If$$s$$ is selected from$$V$$ as the starting vertex, then$$\Psi = ( \psi: \psi = \{v, p, \zeta\} \land v \in V \land p = \infty \land (\zeta = 0) \land ((v = s) \implies p = 0))$$ ; where$$\zeta$$ is a predicate holding Zero if the structure is not selected before by algorithm-II, and One if the structure is selected before as a result of applying algorithm-II. - Algorithm-II (Pull Lesser Distant Vertex): Let
$$p_{lesser}$$ be the lesser distance from the initial vertex$$s$$ ; then the selected lesser distance structure would be$$\psi_{lesser} = \{v, \rho, \zeta | \rho = p_{lesser} \land (\zeta = 0)\}$$ . If$$\psi_{lesser} = \{v, \rho, \zeta | \rho = p_{lesser} \land (\zeta = 0) \land (v = e) \land e\ is\ the\ end\ vertex \}$$ ; then terminate the algorithm; after the selection is made,$$\zeta$$ is switched to$$1$$ . - Algorithm-III (Update the position-dependent sequence with new positions):
- Recall,
$$\psi_{lesser}$$ is a structure in the sequence$$\Psi$$ holding the lesser positioned vertex from the source vertex$$s$$ , the$$\rho$$ value; - Recall
$$m_{ij}$$ ; where$$i$$ is the index of the vertex selected from$$\psi_{lesser}$$ , and$$j$$ is the index of the vertex reachable from$$i$$ , the entry of the adjacency matrix is the distance$$i \rightarrow j$$ ; therefore$$\rho + m_{ij}$$ represents the total distance from the source vertex$$s$$ ; as$$\rho$$ is an incremental value; hence if the predicate$$\rho + m_{ij} < \psi_{j}$$ is true; then update the$$\psi_{j}$$ as$$\psi_{j} = \rho + m_{ij}$$ . Hence,$$(\ (\rho + m_{ij} < \psi_{j}) \implies (\psi_{j} = \rho + m_{ij})\ )$$ .
- Recall,