bmichotte / dijkstra
php 7+ implementation of the Dijkstra algorithm
Installs: 1 451
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 3
Forks: 3
Open Issues: 0
Requires
- php: ^7.1
- ext-bcmath: *
Requires (Dev)
- ext-gd: *
- phpunit/phpunit: ^7.5|^8.0
- scrutinizer/ocular: ^1.5
This package is auto-updated.
Last update: 2024-10-17 19:51:44 UTC
README
More on the algorithm : https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
You can find an example on the example
directory. The result of this example should be something like
Installation
Run composer require bmichotte/dijkstra
Usage
// create some points $point1 = new \Bmichotte\Dijkstra\Point(/* x */ 1, /* y */ 1); $point2 = new \Bmichotte\Dijkstra\Point(2, 2); $point3 = new \Bmichotte\Dijkstra\Point(3, 3); $all_points = [$point1, $point2, $point3]; // "join" them $point1->addPoint($point2); $point1->addPoint($point3); $point2->addPoint($point3); // find the shortest path $dijkstra = new \Bmichotte\Dijkstra\Dijkstra($all_points, /* from */ $point1, /* to */ $point3); $shortest_path = $dijkstra->findShortestPath(); // $shortest_path[0] == $point1 // $shortest_path[1] == $point3