Skip to content

Shortest Path (Dijkstra’s Algorithm) with User Input in PHP/HTML

Notifications You must be signed in to change notification settings

ncjsvr/ShortestPath-Dijkstra-Algorithm-InputForm

Repository files navigation

ShortestPath-Dijkstra-Algorithm-InputForm

Shortest Path (Dijkstra’s Algorithm) with User Input in PHP/HTML

Recently I needed to calculate the shortest path from point to point, I did some research and discovered Dijkstra’s Algorithm. After scouring the web I found a working example in PHP by Doug on Github. All credit can go to him for the actual php scripting, I am simply showing you how to add a user input form. 🙂

My own problem was I needed the algorithm to calculate the shortest path based on a users input. So I had to modify the files to allow this, I’m not going to do a long tutorial for this I am just going to show you the code so you know how to quickly achieve this. You can then apply styles where needed.

Not all locations can travel everywhere, so when the user inputs their choices, it will calculate the path. You will need the following 3 files. You need to edit Travel.php to modify the array of locations, you can see I have it set up here with A, B, C, D and E. You will also need to edit the form at the bottom to include the choices.

About

Shortest Path (Dijkstra’s Algorithm) with User Input in PHP/HTML

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages