Write a program to take a graph (from either standard input or a file, your choice) and find a shortest path in the graph.
Graphs are specified using the following format:
A---S F--T
| / \ |
| / 5 0
|/ \|
D----3--E
A-Z: nodes in the graph
-|/\: edges in the graph
0-9: weights on the edges
<space>: all the holes
All edges are undirected and lie along one of the 8 cardinal directions (i.e., no bends). Edges may optionally contain a weight from 0 to 9. The weight will not be on the last symbol that connects the edge to a node (i.e. edges need to have at least 3 symbols to contain a weight). Unweighted edges have a default weight of 1.
Your code should compute the shortest path between nodes S
and T
and print the length and the path, like this:
5:SDEFT
Shortest correct program wins.
AS0,SD0,SE5,DE3,FE0,FT0
(you could omit the commas if each entry is 3 bytes long.) \$\endgroup\$