Find the minimum travel distance between two nodes. Supports directed graphs, custom weights, and coordinates. Export tables, verify steps, and trust every result today.
| From | To | Weight | Note |
|---|---|---|---|
| A | B | 7 | Edge list weight |
| A | C | 9 | Edge list weight |
| C | F | 2 | Short shortcut edge |
| F | E | 9 | Connects to destination |
Dijkstra relaxation: For each edge (u,v) with weight w, update
dist[v] = min(dist[v], dist[u] + w)
This repeats by permanently selecting the unvisited node with the smallest current distance. It requires non-negative weights.
Euclidean weight (optional): If coordinates are provided,
w = √((x2-x1)² + (y2-y1)²) or √((x2-x1)² + (y2-y1)² + (z2-z1)²).
from,to,weight.In applied physics, "shortest" often means "least cumulative cost," not only least distance. A cost can represent travel time, energy, attenuation, pressure drop, or any scalar you can add along a route. This calculator maps that cost onto a weighted graph and returns an optimal route between two nodes.
Model each junction, station, component, or waypoint as a node and each allowed transition as an edge. Examples include lab floor plans, robot waypoint maps, waveguide connections, and transport networks. Your edge list becomes a compact model you can revise when the setup changes.
Edge weights are the quantities that get summed along a path. If you use meters, the result is in meters; if you use seconds, it becomes minimum travel time. Keep units consistent and non-negative so the output remains physically meaningful and numerically stable.
With coordinates, Euclidean mode computes edge weights from node positions in 2D or 3D. It works well for map-like layouts where distance approximates time or traversal cost. Coordinates do not create connections by themselves; edges still define which pairs are allowed to link.
Undirected graphs assume motion is symmetric: if A connects to B, then B connects to A with the same cost. Directed graphs represent one-way movement, asymmetric resistances, or constraint-driven routing. Direction can change reachability and can produce different optimal routes even when weights look similar.
The calculator uses Dijkstra relaxation, repeatedly settling the unvisited node with the smallest known distance and updating neighbors using dist[v] = min(dist[v], dist[u] + w). For typical lab and classroom networks, this approach is fast and easy to interpret.
Negative weights are rejected because they break Dijkstra assumptions. Missing weights can be skipped, but skipping may disconnect the graph and eliminate valid routes. In Euclidean mode, ensure endpoints have coordinates or provide fallback weights in the edge list.
The Results panel shows the shortest distance, the chosen path, and a distance table for all nodes. Infinity means unreachable under the current settings and skipped edges. Use CSV for spreadsheet analysis and PDF for sharing results in reports.
Provided weights use the numeric values in your edge list. Euclidean weights compute each edge cost from node coordinates. Connectivity still comes from the edge list in both cases.
No. Dijkstra requires non-negative weights. If you need negative edges, switch to a method like Bellman-Ford in a different tool, or transform the model so all costs are non-negative.
Infinity indicates a node is unreachable from the selected start node given your direction setting and the edges you provided or skipped.
Choose Directed and list only the allowed direction, such as A,B,5. If the reverse is allowed with a different cost, add B,A,7 as a separate edge.
Either add weights to every edge, or enable the option to skip missing weights. In Euclidean mode, missing weights are fine only when both endpoint coordinates are present.
Yes. Provide node,x,y,z in the coordinate list. The calculator will use the 3D Euclidean distance for edges whose endpoints both include z values.
It returns one shortest path based on the relaxation order. If multiple paths tie exactly, the reported path may differ depending on node labels and edge ordering, while the shortest distance remains correct.
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.