Weighted shortest path

Find paths and reachable distances in a directed graph with nonnegative edge weights.

The example value has been entered. Check it immediately or change the value.

Input is processed in the browser. Refreshing returns a sample value.

Result

Instructions and example

d(v)=min(d(v),d(u)+w(u,v))

The default graph reaches D via A→C→B→D with total weight 4.

At most 30 nodes and 100 edges; negative edge weights are unsupported.

Frequently asked questions

Are shortest-path edges automatically bidirectional?

No. Edges are directed; add a reverse edge for a bidirectional connection.

What if a shortest-path destination is unreachable?

The result shows no path and infinite distance. Disconnection is not treated as distance 0.

Calculation criteria and reference materials

Verification of calculation criteria: · Calculation·verification principles · Report errors