The Bellman-Ford algorithm for shortest paths

Enter the adjacency list of your graph. Each line must start with a vertex label. The other tokens in the line for a vertex u describe the adjacency list of u. They must come in pairs v w, where (u,v) is an edge and w is its weight. Separate all tokens with space(s).

In the example below, the vertex s is adjacent with vertices t and y, and the edge weights of (s,t) and (s,y) are 6 and 7, respectively.

The maximum input length is limited by 300 characters including spaces.

Source:

Program output

Source code