Théorie des graphes : Types de graphes et parcours

Fundamental Concepts and Graph Typology

  • Definition of Graph Orientation Types:

    • Directed Graph (Graphe orienté): A graph containing exclusively directed edges, known as arcs. Graphs G1G_1 and G4G_4 are examples of directed graphs.
    • Undirected Graph (Graphe non orienté): A graph containing exclusively undirected edges, known as edges (arêtes). Graphs G2G_2 and G5G_5 are examples of undirected graphs.
    • Mixed Graph (Graphe mixte): A graph containing both directed edges (arcs) and undirected edges (edges). Graph G3G_3 is an example of a mixed graph.
    • Orientation Inversion Rule: In a directed graph, if an arc is traversed in the indirect direction (contrary to the arrow's orientation), the arc is treated and classified as an edge.
  • Definition and Interpretations of Weighted Graphs (Graphes valués):

    • Definition: A graph is valued (or weighted) if every arc or edge is assigned a numerical value, typically denoted by lijl_{ij}. Graph G1G_1 is a valued graph, whereas the other graphs are unweighted.
    • Physical and Operational Interpretations of lijl_{ij}:
    • The physical distance between vertex xix_i and vertex xjx_j.
    • The travel time or transit duration required to move from xix_i to xjx_j.
    • The travel or transportation cost incurred from xix_i to xjx_j.
    • The maximum capacity of information, data packets, or physical merchandise permitted to traverse the arc.
    • The maximum flow capacity transferable from vertex xix_i to vertex xjx_j.
  • Graph Connectivity Categories:

    • Connected Graph (Graphe connexe): A graph where any two arbitrary vertices are linked to one another by either a path or a chain. Graph G2G_2 is connected.
    • Non-Connected Graph (Graphe non connexe): A graph where there exist at least two vertices that are not connected by any path or chain. Graph G5G_5 is non-connected.
    • Strongly Connected Graph (Graphe fortement connexe): A directed graph where any two arbitrary vertices are obligatorily connected to each other by a directed path in both directions. Graph G1G_1 is strongly connected.
  • Vertex Degrees and Formulas:

    • General Degree: The degree of a vertex xix_i in a graph is the total count of arcs or edges adjacent to that vertex.
    • Directed Graph Demidegrees:
    • In-Degree (Demi-degré intérieur) dG−(xi)d_G^-(x_i): The total count of incoming arcs entering vertex xix_i.
    • Out-Degree (Demi-degré extérieur) dG+(xi)d_G^+(x_i): The total count of outgoing arcs leaving vertex xix_i.
    • Total Degree Equation: The total degree of a vertex xix_i equals the arithmetic sum of its in-degree and its out-degree:       dG(xi)=dG−(xi)+dG+(xi)d_G(x_i) = d_G^-(x_i) + d_G^+(x_i)
    • Concrete Degree Values:
    • In graph G1G_1: for vertex x3x_3, dG−(x3)=2d_G^-(x_3) = 2, dG+(x3)=2d_G^+(x_3) = 2, yielding total degree dG1(x3)=4d_{G_1}(x_3) = 4.
    • In graph G1G_1: for vertex x7x_7, dG−(x7)=5d_G^-(x_7) = 5, dG+(x7)=1d_G^+(x_7) = 1, yielding total degree dG1(x7)=6d_{G_1}(x_7) = 6.
    • In graph G2G_2: for vertex x1x_1, total degree dG2(x1)=6d_{G_2}(x_1) = 6.
  • Regular Graphs (Graphe régulier):

    • Definition: A graph is termed regular if and only if all vertices in the graph share the identical degree.
    • Example: Graph G5G_5 is a regular graph.
  • Predecessors, Successors, Graph Entries, and Graph Exits:

    • Predecessor (Prédécesseur): For a given directed arc (xi,xj)(x_i, x_j), vertex xix_i is the initial extremity and is designated as the predecessor of vertex xjx_j. Equivalently, xix_i is a predecessor of xjx_j if there exists an arc having xix_i as its origin and xjx_j as its destination. The set of all predecessors of vertex xix_i is denoted by Γ−(xi)\Gamma^-(x_i).
    • Successor (Successeur): For a given directed arc (xi,xj)(x_i, x_j), vertex xjx_j is the terminal extremity and is designated as the successor of vertex xix_i. Equivalently, xjx_j is a successor of xix_i if there exists an arc having xix_i as its origin and xjx_j as its destination. The set of all successors of vertex xix_i is denoted by Γ+(xi)\Gamma^+(x_i).
    • Graph Entry / Source (Entrée du graphe): If Γ−(xi)=∅\Gamma^-(x_i) = \emptyset, vertex xix_i has no incoming arcs and is called an entry of the graph.
    • Graph Exit / Sink (Sortie du graphe): If Γ+(xi)=∅\Gamma^+(x_i) = \emptyset, vertex xix_i has no outgoing arcs and is called an exit of the graph.
    • Concrete Examples from Graph G1G_1:
    • Γ−(x1)=∅\Gamma^-(x_1) = \emptyset: Vertex x1x_1 constitutes the entry of graph G1G_1.
    • Γ+(x1)={x2,x3,x7,x8}\Gamma^+(x_1) = \{x_2, x_3, x_7, x_8\}.
    • Γ−(x7)={x1}\Gamma^-(x_7) = \{x_1\}; Γ+(x7)={x3,x5,x8,x9}\Gamma^+(x_7) = \{x_3, x_5, x_8, x_9\}.
    • Γ−(x2)={x1}\Gamma^-(x_2) = \{x_1\}; Γ+(x2)={x4,x6}\Gamma^+(x_2) = \{x_4, x_6\}.
    • Γ+(x11)=∅\Gamma^+(x_{11}) = \emptyset: Vertex x11x_{11} constitutes the exit of graph G1G_1.

Paths, Chains, Circuits, and Cycles

  • Fundamental Sequence Definitions:

    • Path (Chemin): A sequence of arcs sharing common extremities, such that the terminal extremity of the preceding arc becomes the initial extremity of the immediately succeeding arc.
    • Chain (Chaîne): A sequence of undirected edges sharing common extremities, such that the terminal extremity of the preceding edge becomes the initial extremity of the succeeding edge.
    • Transformation Rule: If an undirected edge is introduced into a path, that path ceases to be a path and becomes a chain.
    • Circuit (Circuit): A path that begins and terminates at the very same vertex (a closed directed path).
    • Cycle (Cycle): A chain that begins and terminates at the very same vertex (a closed undirected sequence of edges).
  • Subtypes of Paths:

    • Optimal or Critical Path (Chemin critique ou optimal): A path exhibiting the maximal possible value (longest path) or the minimal possible value (shortest path). Minimization scenarios define the shortest path, whereas maximization scenarios define the longest path.
    • Elementary Path (Chemin élémentaire): A path traversing any given vertex of the graph at most once (one and only once).
    • Simple Path (Chemin simple): A path traversing any given arc of the graph at most once (one and only once).
    • Hamiltonian Path (Chemin hamiltonien): A path traversing every single vertex of the graph exactly once (one and only once).
  • Concrete Examples and Counterexamples:

    • In graph G1G_1:
    • Paths: x2→x4→x6x_2 \rightarrow x_4 \rightarrow x_6 is a path, where (x2,x4)(x_2, x_4) and (x4,x6)(x_4, x_6) are arcs.
    • Chains: If edges (x7,x4)(x_7, x_4) and (x4,x5)(x_4, x_5) are present, the sequence x1→x3→x7→x5x_1 \rightarrow x_3 \rightarrow x_7 \rightarrow x_5 constitutes a chain.
    • Elementary Paths: x1→x3→x4x_1 \rightarrow x_3 \rightarrow x_4 and x5→x6x_5 \rightarrow x_6 are elementary paths because each vertex appears once.
    • Simple Non-Elementary Path: x1→x7→x8→x9→x10→x11x_1 \rightarrow x_7 \rightarrow x_8 \rightarrow x_9 \rightarrow x_{10} \rightarrow x_{11} traverses no arc twice, qualifying as simple, but may not be elementary if a vertex repeats.
    • Non-Simple Non-Elementary Path: A sequence such as x3→x7→x10→x3→…x_3 \rightarrow x_7 \rightarrow x_{10} \rightarrow x_3 \rightarrow \dots that revisits both vertices and arcs is neither simple nor elementary.
    • Hamiltonian Path: The path sequence x1→x2→x4→x6→x7→x5→x8→x9→x10→x11x_1 \rightarrow x_2 \rightarrow x_4 \rightarrow x_6 \rightarrow x_7 \rightarrow x_5 \rightarrow x_8 \rightarrow x_9 \rightarrow x_{10} \rightarrow x_{11} visits every vertex of graph G1G_1 once and only once.
    • In graph G2G_2:
    • Edges: (x1,x2)(x_1, x_2) and (x2,x3)(x_2, x_3) are edges.
    • Chain: The progression x1−x2−x3−x4−x5x_1 - x_2 - x_3 - x_4 - x_5 is an undirected chain.
    • Cycle: The closed loop x1−x2−x5−x3−x1x_1 - x_2 - x_5 - x_3 - x_1 starts and ends at x1x_1, forming a cycle.

Forms of Graph Presentation

  • Sagittal Form (Forme sagittale):

    • A graphical, diagrammatic representation plotted in the geometric plane depicting the complete set of vertices together with their connecting arcs or edges. Graphs G1G_1 through G5G_5 are presented under this sagittal form.
  • Matrix Form (Forme matricielle):

    • A double-entry matrix where rows designate the initial extremity vertices (predecessors) and columns designate the terminal extremity vertices (successors).
    • At the intersection of row ii and column jj, the matrix entry is set to the weight lijl_{ij} if arc (xi,xj)(x_i, x_j) exists, and 00 if the arc does not exist.
    • Whether structured by successor/predecessor or predecessor/successor orientation, the structural matrix remains invariant.
  • Dictionary Form (Forme du dictionnaire):

    • A comprehensive tabular schedule recording, for each individual vertex, its exhaustive set of predecessors and its exhaustive set of successors.
    • Complete Dictionary for Graph G1G_1 (Vertices x1x_1 through x11x_{11}):
    • Vertex x1x_1: Predecessors Γ−(x1)=∅\Gamma^-(x_1) = \emptyset; Successors Γ+(x1)={x2,x3,x7,x8}\Gamma^+(x_1) = \{x_2, x_3, x_7, x_8\}
    • Vertex x2x_2: Predecessors Γ−(x2)={x1}\Gamma^-(x_2) = \{x_1\}; Successors Γ+(x2)={x4,x6}\Gamma^+(x_2) = \{x_4, x_6\}
    • Vertex x3x_3: Predecessors Γ−(x3)={x1,x7}\Gamma^-(x_3) = \{x_1, x_7\}; Successors Γ+(x3)={x4,x5}\Gamma^+(x_3) = \{x_4, x_5\}
    • Vertex x4x_4: Predecessors Γ−(x4)={x2,x3}\Gamma^-(x_4) = \{x_2, x_3\}; Successors Γ+(x4)={x6}\Gamma^+(x_4) = \{x_6\}
    • Vertex x5x_5: Predecessors Γ−(x5)={x3,x7}\Gamma^-(x_5) = \{x_3, x_7\}; Successors Γ+(x5)={x6}\Gamma^+(x_5) = \{x_6\}
    • Vertex x6x_6: Predecessors Γ−(x6)={x2,x4,x5}\Gamma^-(x_6) = \{x_2, x_4, x_5\}; Successors Γ+(x6)={x11}\Gamma^+(x_6) = \{x_{11}\}
    • Vertex x7x_7: Predecessors Γ−(x7)={x1}\Gamma^-(x_7) = \{x_1\}; Successors Γ+(x7)={x3,x5,x8,x9}\Gamma^+(x_7) = \{x_3, x_5, x_8, x_9\}
    • Vertex x8x_8: Predecessors Γ−(x8)={x1,x7}\Gamma^-(x_8) = \{x_1, x_7\}; Successors Γ+(x8)={x9,x10}\Gamma^+(x_8) = \{x_9, x_{10}\}
    • Vertex x9x_9: Predecessors Γ−(x9)={x7,x8}\Gamma^-(x_9) = \{x_7, x_8\}; Successors Γ+(x9)={x10}\Gamma^+(x_9) = \{x_{10}\}
    • Vertex x10x_{10}: Predecessors Γ−(x10)={x8,x9}\Gamma^-(x_{10}) = \{x_8, x_9\}; Successors Γ+(x10)={x11}\Gamma^+(x_{10}) = \{x_{11}\}
    • Vertex x11x_{11}: Predecessors Γ−(x11)={x6,x10}\Gamma^-(x_{11}) = \{x_6, x_{10}\}; Successors Γ+(x11)=∅\Gamma^+(x_{11}) = \emptyset
  • Exhaustive List Form (Forme d'une liste exhaustive des sommets et arcs):

    • An explicit set-theoretic enumeration listing in extension the complete set of all vertices VV and the complete set of all directed arcs or edges EE comprising the graph.

Vertex Level Decomposition Algorithm

  • Conceptual Definition and Operational Role:

    • The level of a vertex in a directed acyclic graph represents the maximal number of paths (or maximal path length) extending from the graph entry to that vertex.
    • It serves as an indicator of the degree of utilization of each vertex, dictating the precise topological rank and sequential order in which vertices must be evaluated in optimization algorithms.
  • Step-by-Step Construction Procedure:

    • Level 1 (Niveau 1): Identify all vertices possessing no predecessors in the predecessor dictionary. Assign these vertices to Level 1. In graph G1G_1, this is vertex x1x_1.
    • Level 2 (Niveau 2): Temporarily eliminate the Level 1 vertices from the predecessor listings. Identify all vertices that now have no remaining predecessors. Assign these vertices to Level 2. In graph G1G_1, these are vertices x2x_2 and x7x_7.
    • Iterative Levels (Niveau 3 onwards): Continue this elimination procedure iteratively until all predecessors have been processed and removed from every vertex.
  • Exhaustive Level Assignment for Graph G1G_1:

    • Level 1: x1x_1
    • Level 2: x2,x7x_2, x_7
    • Level 3: x3,x8x_3, x_8
    • Level 4: x4,x5x_4, x_5
    • Level 5: x9x_9
    • Level 6: x6x_6
    • Level 7: x10x_{10}
    • Level 8: x11x_{11}

Ford's Algorithm for Optimal Paths

  • Objective and Applicability Conditions:

    • Designed to construct an optimal path (shortest or longest) from the entry vertex to the exit vertex of a directed, valued, connected graph whose vertices are defined by their sets of predecessors.
    • Requires topological ordering of vertices by levels to prevent cyclic dependencies.
  • Algorithmic Principle and Potential Formulation:

    • Each vertex xjx_j is assigned a scalar potential/coefficient denoted by λj\lambda_j, representing the cumulative optimal value of the path originating from the entry vertex up to vertex xjx_j.
    • Step 1 (Ranking): Sort and rank all graph vertices into sequential levels.
    • Step 2 (Initialization): Assign coefficient 00 to the entry vertex:     λentry=0\lambda_{\text{entry}} = 0
    • Step 3 (Recurrence Relation):
    • For the shortest path (minimization):       λj=min⁡i∈Γ−(xj)(λi+lij)\lambda_j = \min_{i \in \Gamma^-(x_j)} (\lambda_i + l_{ij})
    • For the longest path (maximization):       λj=max⁡i∈Γ−(xj)(λi+lij)\lambda_j = \max_{i \in \Gamma^-(x_j)} (\lambda_i + l_{ij})
    • Step 4 (Termination): If xnx_n denotes the exit vertex of the graph, the computed coefficient λn\lambda_n represents the optimal path value connecting the entry to the exit.
  • Comprehensive Step-by-Step Shortest Path Evaluation on Graph G1G_1:

    • Entry Initialization:λ1=0\lambda_1 = 0
    • Vertex x2x_2:λ2=min⁡i∈Γ−(x2)(λi+li,2)=min⁡(λ1+l1,2)=min⁡(0+2)=2\lambda_2 = \min_{i \in \Gamma^-(x_2)} (\lambda_i + l_{i,2}) = \min(\lambda_1 + l_{1,2}) = \min(0 + 2) = 2
    • Vertex x7x_7:λ7=min⁡i∈Γ−(x7)(λi+li,7)=min⁡(λ1+l1,7)=min⁡(0+2)=2\lambda_7 = \min_{i \in \Gamma^-(x_7)} (\lambda_i + l_{i,7}) = \min(\lambda_1 + l_{1,7}) = \min(0 + 2) = 2
    • Vertex x3x_3:λ3=min⁡i∈Γ−(x3)(λi+li,3)=min⁡(λ1+l1,3,λ7+l7,3)=min⁡(0+10,2+12)=min⁡(10,14)=10\lambda_3 = \min_{i \in \Gamma^-(x_3)} (\lambda_i + l_{i,3}) = \min(\lambda_1 + l_{1,3}, \lambda_7 + l_{7,3}) = \min(0 + 10, 2 + 12) = \min(10, 14) = 10
    • Vertex x8x_8:λ8=min⁡i∈Γ−(x8)(λi+li,8)=min⁡(λ1+l1,8,λ7+l7,8)=min⁡(0+15,2+9)=min⁡(15,11)=11\lambda_8 = \min_{i \in \Gamma^-(x_8)} (\lambda_i + l_{i,8}) = \min(\lambda_1 + l_{1,8}, \lambda_7 + l_{7,8}) = \min(0 + 15, 2 + 9) = \min(15, 11) = 11
    • Vertex x5x_5:λ5=min⁡i∈Γ−(x5)(λi+li,5)=min⁡(λ3+l3,5,λ7+l7,5)=min⁡(10+18,2+8)=min⁡(28,10)=10\lambda_5 = \min_{i \in \Gamma^-(x_5)} (\lambda_i + l_{i,5}) = \min(\lambda_3 + l_{3,5}, \lambda_7 + l_{7,5}) = \min(10 + 18, 2 + 8) = \min(28, 10) = 10
    • Vertex x9x_9:λ9=min⁡i∈Γ−(x9)(λi+li,9)=min⁡(λ7+l7,9,λ8+l8,9)=min⁡(2+12,11+10)=min⁡(14,21)=14\lambda_9 = \min_{i \in \Gamma^-(x_9)} (\lambda_i + l_{i,9}) = \min(\lambda_7 + l_{7,9}, \lambda_8 + l_{8,9}) = \min(2 + 12, 11 + 10) = \min(14, 21) = 14
    • Vertex x4x_4:λ4=min⁡i∈Γ−(x4)(λi+li,4)=min⁡(λ3+l3,4,λ5+l5,4)=min⁡(10+2,10+4)=min⁡(12,14)=12\lambda_4 = \min_{i \in \Gamma^-(x_4)} (\lambda_i + l_{i,4}) = \min(\lambda_3 + l_{3,4}, \lambda_5 + l_{5,4}) = \min(10 + 2, 10 + 4) = \min(12, 14) = 12
    • Vertex x6x_6:λ6=13\lambda_6 = 13
    • Vertex x10x_{10}:λ10=17\lambda_{10} = 17
    • Vertex x11x_{11} (Exit):λ11=19\lambda_{11} = 19
    • Final Shortest Path Value: The shortest path between entry x1x_1 and exit x11x_{11} equals 1919.
    • Path Reconstruction: The optimal shortest path trajectory is determined by tracing back the minimizing predecessors starting from the exit vertex x11x_{11} back to the entry vertex x1x_1.

Dijkstra's Algorithm for Shortest Paths

  • Objective and Scope:

    • Determines the shortest path connecting the entry vertex to the exit vertex of a directed, connected graph with non-negative arc valuations, where vertices are defined by their sets of successors.
  • Algorithmic Principle and Step-by-Step Procedure:

    • Assigns each vertex xjx_j a label Coef(xj)\text{Coef}(x_j) reflecting the shortest distance from the entry vertex.
    • Step 1 (Initialization):
    • In the initial row of an evaluation matrix, list all vertices of the graph.
    • Assign coefficient 00 to the entry vertex and +∞+\infty to all other vertices.
    • Select the entry vertex (marking it as permanent) and eliminate its corresponding column from further selection.
    • Step 2 (Initial Current Row Construction):
    • For every vertex xjx_j that is a direct successor of the entry vertex, set Coef(xj)\text{Coef}(x_j) to the value of the arc spanning from the entry to xjx_j.
    • Retain all other vertex coefficients at +∞+\infty.
    • Identify and select the uneliminated vertex possessing the minimum coefficient, and eliminate its column.
    • Step 3 (Iterative Row Updates):
    • Let xix_i be the vertex selected in the previous iteration.
    • For every uneliminated successor vertex xj∈Γ+(xi)x_j \in \Gamma^+(x_i), compute its candidate coefficient:       NCoef(xj)=Coef(xi)+lij\text{NCoef}(x_j) = \text{Coef}(x_i) + l_{ij}
    • If NCoef(xj)<Coef(xj)\text{NCoef}(x_j) < \text{Coef}(x_j), overwrite the label: Coef(xj)←NCoef(xj)\text{Coef}(x_j) \leftarrow \text{NCoef}(x_j).
    • If NCoef(xj)≥Coef(xj)\text{NCoef}(x_j) \ge \text{Coef}(x_j), maintain the existing label value unchanged.
    • For vertices that are not direct successors of xix_i, carry over their coefficients unchanged.
    • Select the vertex displaying the strictly smallest coefficient across the current row, and eliminate its column.
    • Step 4 (Stopping Criterion):
    • If all matrix columns have been eliminated, terminate the procedure.
    • Otherwise, repeat Step 3.
  • Tabular Execution and Selection Sequence for Graph G1G_1:

    • Columns track vertices x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_{10}, x_{11}.
    • Row 1: x1=0x_1 = 0, all others +∞+\infty. Select x1x_1 with coefficient 00.
    • Row 2: Successors of x1x_1 updated: x2=2x1x_2 = 2_{x_1}, x3=10x1x_3 = 10_{x_1}, x7=2x1x_7 = 2_{x_1}, x8=15x1x_8 = 15_{x_1}. Minimal coefficient is 22 (tie between x2x_2 and x7x_7). Select x2x_2 with coefficient 22.
    • Row 3: Successors of x2x_2 evaluated: x4=2+4=6x2x_4 = 2 + 4 = 6_{x_2}, x6=2+18=20x2x_6 = 2 + 18 = 20_{x_2}. Minimal coefficient across active vertices is 22 at x7x_7. Select x7x_7 with coefficient 22.
    • Row 4: Successors of x7x_7 evaluated: x5=2+8=10x7x_5 = 2 + 8 = 10_{x_7}, x8=min⁡(15,2+9)=11x7x_8 = \min(15, 2 + 9) = 11_{x_7}, x9=2+12=14x7x_9 = 2 + 12 = 14_{x_7}. Minimal coefficient is 66 at x4x_4. Select x4x_4 with coefficient 66.
    • Row 5: Successors of x4x_4 evaluated: updates x6x_6 to min⁡(20,6+7)=13x4\min(20, 6 + 7) = 13_{x_4} or 12x412_{x_4}. Minimal active labels evaluated. Iteratively selects vertices: x3x_3 (Coef=10\text{Coef} = 10), x5x_5 (Coef=10\text{Coef} = 10), x8x_8 (Coef=11\text{Coef} = 11), x6x_6 (Coef=12\text{Coef} = 12), x9x_9 (Coef=14\text{Coef} = 14), x10x_{10} (Coef=17\text{Coef} = 17), and finally x11x_{11} (Coef=19\text{Coef} = 19).
    • Final Output: The optimal shortest path terminates at exit vertex x11x_{11} with a minimal cumulative distance of 1919.

Floyd-Warshall Algorithm for All-Pairs Shortest Paths

  • Objective and Specific Characteristics:

    • Determines the complete matrix of shortest paths between every pair of arbitrary vertices in a weighted graph.
    • Supports both directed and undirected graphs.
    • Accommodates arbitrary capacities or edge weights that need not be strictly positive, provided there exist no negative/absorbent circuits.
  • Algorithmic Framework and Dual Matrices:

    • Operates by iteratively generating a distance matrix MkM_k (shortest path lengths) and a tracking matrix SkS_k (intermediate routing vertices).
    • Step 0 (Initialization):
    • Assume all vertices are initially connected only by direct arcs.
    • Construct initial matrix M0M_0 where entry (i,j)(i, j) is the direct edge length lijl_{ij}, with diagonal elements set to 00 and non-adjacent pairs set to +∞+\infty.
    • Construct intermediate vertex matrix S0S_0 where entry S0(i,j)=jS_0(i, j) = j if a direct connection exists, and 00 otherwise.
    • Step kk (Routing via Vertex xkx_k):
    • At iteration kk, vertex xkx_k is introduced as an intermediate routing vertex.
    • For every pair of vertices (xi,xj)(x_i, x_j), compare two path alternatives:
      • Direct path from xix_i to xjx_j with current length lijl_{ij}.
      • Indirect path via xkx_k (xi→xk→xjx_i \rightarrow x_k \rightarrow x_j) with combined length lik+lkjl_{ik} + l_{kj}.
    • Update Condition:
      • If lik+lkj<lijl_{ik} + l_{kj} < l_{ij}:
      • In matrix MkM_k, update the cell: Mk(i,j)=lik+lkjM_k(i, j) = l_{ik} + l_{kj}.
      • In matrix SkS_k, record the intermediate vertex: Sk(i,j)=xkS_k(i, j) = x_k.
      • If lik+lkj≥lijl_{ik} + l_{kj} \ge l_{ij}:
      • In matrix MkM_k, maintain the previous value: Mk(i,j)=Mk−1(i,j)M_k(i, j) = M_{k-1}(i, j).
      • In matrix SkS_k, maintain the previous entry: Sk(i,j)=Sk−1(i,j)S_k(i, j) = S_{k-1}(i, j).
    • Matrix Construction Invariant: Row kk and column kk remain completely unchanged when transitioning from Mk−1M_{k-1} to MkM_k.
    • Step NN (Termination Criterion):
    • For a graph containing nn vertices, the process concludes after constructing matrix MnM_n and matrix SnS_n, fixing vertex xnx_n as the final intermediate node.
    • MnM_n contains the all-pairs shortest distances; SnS_n allows the reconstruction of all optimal paths.
  • Interpretation and Path Reconstruction from Matrix SS:

    • If Sij=jS_{ij} = j, vertex xix_i is directly connected to vertex xjx_j along the optimal path.
    • If Sij=kS_{ij} = k (with k≠jk \ne j), the optimal trajectory from xix_i to xjx_j traverses intermediate vertex xkx_k, requiring decomposition into subpaths xi→xkx_i \rightarrow x_k and xk→xjx_k \rightarrow x_j.
  • Full Execution on a 5-Vertex Graph (x1x_1 through x5x_5):

    • Initial State (k=0k=0):
    • Direct distance matrix M0M_0:       (028∞120∞648∞012∞610214220)\begin{pmatrix} 0 & 2 & 8 & \infty & 1 \\ 2 & 0 & \infty & 6 & 4 \\ 8 & \infty & 0 & 1 & 2 \\ \infty & 6 & 1 & 0 & 2 \\ 1 & 4 & 2 & 2 & 0 \end{pmatrix}
    • Intermediate tracking matrix S0S_0:       (0230510045100450230512340)\begin{pmatrix} 0 & 2 & 3 & 0 & 5 \\ 1 & 0 & 0 & 4 & 5 \\ 1 & 0 & 0 & 4 & 5 \\ 0 & 2 & 3 & 0 & 5 \\ 1 & 2 & 3 & 4 & 0 \end{pmatrix}
    • Iteration 1 (k=1k=1, Vertex x1x_1 Fixed):
    • Updating paths through x1x_1: for example, path from x2x_2 to x5x_5 via x1x_1 has length l2,1+l1,5=2+1=3<4l_{2,1} + l_{1,5} = 2 + 1 = 3 < 4, updating M1(2,5)=3M_1(2, 5) = 3 and S1(2,5)=1S_1(2, 5) = 1.
    • Distance matrix M1M_1:       (028∞1201063810012∞610213220)\begin{pmatrix} 0 & 2 & 8 & \infty & 1 \\ 2 & 0 & 10 & 6 & 3 \\ 8 & 10 & 0 & 1 & 2 \\ \infty & 6 & 1 & 0 & 2 \\ 1 & 3 & 2 & 2 & 0 \end{pmatrix}
    • Tracking matrix S1S_1:       (0230510141110450230511340)\begin{pmatrix} 0 & 2 & 3 & 0 & 5 \\ 1 & 0 & 1 & 4 & 1 \\ 1 & 1 & 0 & 4 & 5 \\ 0 & 2 & 3 & 0 & 5 \\ 1 & 1 & 3 & 4 & 0 \end{pmatrix}
    • Iteration 2 (k=2k=2, Vertex x2x_2 Fixed):
    • Row 2 and Column 2 remain invariant. Updates paths passing through x2x_2.
    • Distance matrix M2M_2:       (028812010638100128610213220)\begin{pmatrix} 0 & 2 & 8 & 8 & 1 \\ 2 & 0 & 10 & 6 & 3 \\ 8 & 10 & 0 & 1 & 2 \\ 8 & 6 & 1 & 0 & 2 \\ 1 & 3 & 2 & 2 & 0 \end{pmatrix}
    • Tracking matrix S2S_2:       (0232510141110452230511340)\begin{pmatrix} 0 & 2 & 3 & 2 & 5 \\ 1 & 0 & 1 & 4 & 1 \\ 1 & 1 & 0 & 4 & 5 \\ 2 & 2 & 3 & 0 & 5 \\ 1 & 1 & 3 & 4 & 0 \end{pmatrix}
    • Iteration 3 (k=3k=3, Vertex x3x_3 Fixed):
    • Row 3 and Column 3 remain invariant. Updates paths passing through x3x_3.
    • Distance matrix M3M_3:       (028812010638100128610213220)\begin{pmatrix} 0 & 2 & 8 & 8 & 1 \\ 2 & 0 & 10 & 6 & 3 \\ 8 & 10 & 0 & 1 & 2 \\ 8 & 6 & 1 & 0 & 2 \\ 1 & 3 & 2 & 2 & 0 \end{pmatrix}
    • Tracking matrix S3S_3 incorporates routing node updates.
    • Iteration 4 (k=4k=4, Vertex x4x_4 Fixed):
    • Row 4 and Column 4 remain invariant. Distance matrix M4M_4 and tracking matrix S4S_4 calculated.
    • Iteration 5 (k=5k=5, Vertex x5x_5 Fixed):
    • Final distance matrix M5M_5:       (0233120553350123510213220)\begin{pmatrix} 0 & 2 & 3 & 3 & 1 \\ 2 & 0 & 5 & 5 & 3 \\ 3 & 5 & 0 & 1 & 2 \\ 3 & 5 & 1 & 0 & 2 \\ 1 & 3 & 2 & 2 & 0 \end{pmatrix}
    • Final tracking matrix S5S_5:       (0255510551550455530511340)\begin{pmatrix} 0 & 2 & 5 & 5 & 5 \\ 1 & 0 & 5 & 5 & 1 \\ 5 & 5 & 0 & 4 & 5 \\ 5 & 5 & 3 & 0 & 5 \\ 1 & 1 & 3 & 4 & 0 \end{pmatrix}
  • Optimal Path Extraction Example:

    • To extract the shortest path between vertex x4x_4 and vertex x3x_3:
    • The entry in distance matrix M5(4,3)M_5(4, 3) yields a value of 44 (or 11 if direct, with M5(4,5)+M5(5,3)=2+2=4M_5(4, 5) + M_5(5, 3) = 2 + 2 = 4 depending on orientation).
    • Querying tracking matrix S5(4,3)S_5(4, 3) indicates intermediate vertex x5x_5.
    • The sequence decomposes into x4→x5→x3x_4 \rightarrow x_5 \rightarrow x_3.
    • The optimal cumulative cost for this route equals 44.