taniko / dijkstra
dijkstra algorithm
Installs: 3 518
Dependents: 1
Suggesters: 0
Security: 0
Stars: 20
Watchers: 4
Forks: 8
Open Issues: 1
Requires (Dev)
- phpunit/phpunit: ^5.5
This package is not auto-updated.
Last update: 2024-12-22 06:54:33 UTC
README
Installation
composer require taniko/dijkstra
Usage
$graph = Taniko\Dijkstra\Graph::create(); $graph ->add('s', 'a', 1) ->add('s', 'b', 2) ->add('a', 'b', 2) ->add('a', 'c', 4) ->add('b', 'c', 2) ->add('b', 'd', 5) ->add('c', 'd', 1) ->add('c', 't', 3) ->add('d', 't', 1); $route = $graph->search('s', 't'); // ['s', 'b', 'c', 'd', 't'] $cost = $graph->cost($route); // 6.0