This is a CLI tool for illustrating Dijkstra's shortest path algorithm in routing between computer network layer routers
The links information is provided inside link.json. This tell us from which node to which node what is the cost.
~ $ ./dijkstra --help
Implementation of Dijkstra's Algorithm in go
Usage:
Dijkstra's Algorithm [flags]
Flags:
-e, --end string Enter the End point of the route (default "B")
-h, --help help for Dijkstra's
-s, --start string Enter the starting point of the route (default "A")
-t, --toggle Help message for toggle
- Clone the Repo using
git clone https://github.com/Vinayaks439/Dijkstra-Algorithm-Go
- build the binary using
go build -o dijkstra
- Use -s to indicate starting node and -e to indicate ending node
./dijkstra -s "A" -e "J"
for shorthands - Use --start and --end to provide long hand cli args
- For help use:
./dijkstra --help
~ $ ./dijkstra --start "A" --end "J"
{
"TotalCost": 6,
"Path": [
"A",
"B",
"C",
"J"
]
}
# The total Cost to reach J node from A is 6 and the route is mentioned inside the PATH array one after the other (A -> B -> C -> J)
~ $ ./dijkstra --start "A" --end "F"
{
"TotalCost": 5,
"Path": [
"A",
"B",
"C",
"F"
]
}
# The total Cost to reach F node from A is 5 and the route is mentioned inside the PATH array one after the other (A -> B -> C -> F)
~ $ ./dijkstra --start "K" --end "B"
{
"TotalCost": 5,
"Path": [
"K",
"F",
"C",
"B"
]
}
# The total Cost to reach B node from K is 5 and the route is mentioned inside the PATH array one after the other (K -> F -> C -> B)