All-Source Shortest Path Matrix Calculator

Compute graphs instantly using our advanced mathematical solver today.

Graph Configuration

Matrix Data Input

Separate rows with newlines. Use INF for unreachable paths.

Example Inputs

Copy and paste these presets into the input box to test quickly:

Example 1 (4 Nodes):
0, 3, INF, 7
8, 0, 2, INF
5, INF, 0, 1
2, INF, INF, 0
Example 2 (3 Nodes):
0, 5, INF
INF, 0, 2
3, INF, 0

Understanding All-Source Shortest Path Calculations

Finding the shortest path between every pair of vertices in an edge-weighted directed graph is a fundamental problem in computer science and discrete mathematics. Unlike single-source algorithms like Dijkstra's, all-source algorithms compute paths between all possible node combinations simultaneously. This calculator utilizes optimized matrix multiplication principles and dynamic programming frameworks to evaluate complete graph topologies efficiently.

Formula Used

The core computational engine is built upon the classic dynamic programming recurrence relation popularized by Robert Floyd and Stephen Warshall. The distance matrix update rule at step $k$ is defined formally as:

$$D^{(k)}(i, j) = \min\left(D^{(k-1)}(i, j), \, D^{(k-1)}(i, k) + D^{(k-1)}(k, j)\right)$$

Where $D(i,j)$ represents the shortest distance from vertex $i$ to vertex $j$, and intermediate vertex $k$ acts as an optional stepping stone to check if a shorter composite route exists.

How to Use This Calculator

Frequently Asked Questions

What does INF mean? INF signifies infinity, indicating that no direct edge connects those specific nodes.

Can I use negative numbers? Yes, configure the negative weight setting to enable detection routines for cyclical loops.

Related Calculators

Paver Sand Bedding Calculator (depth-based)Paver Edge Restraint Length & Cost CalculatorPaver Sealer Quantity & Cost CalculatorExcavation Hauling Loads Calculator (truck loads)Soil Disposal Fee CalculatorSite Leveling Cost CalculatorCompaction Passes Time & Cost CalculatorPlate Compactor Rental Cost CalculatorGravel Volume Calculator (yards/tons)Gravel Weight Calculator (by material type)

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.