Skip to content

taniko/dijkstra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dijkstra's algorithm in PHP

Build Status


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

About

Dijkstra's algorithm in PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages