[Close window]

dijkstra.awk - an AWK script to find shortest paths in a graph

dijkstra.awk is an AWK program to solve shortest-path problems over directed graphs. (g)awk is a script engine available by default on most UNIX/Linux distributions. If you're running Windows, you can get gawk.exe from the UnxUtils package available at SourceForge.

The graph example.txt is provided to test the program and to understand the basic idea. You can try it by running gawk -f dijkstra.awk example.txt.

Format of the input file

The input file will be read line by line. Allowed commands are:

Download

You can download the AWK script from here: [dijkstra.awk, 1.8 KB] and the example.txt graph file from here: [example.txt, < 1 KB].