algorithms/dijkstra
最新稳定版本:v3.0.1-alpha.1
Composer 安装命令:
composer require algorithms/dijkstra
包简介
Implementation of Dijkstra's algorithm.
README 文档
README
My implementation of famous the algorithm for finding the shortest paths in a graph. Discovered by Edsger Dijkstra.
Composer
Use in your console
composer require phpalgorithms/dijkstra
How to use
Create connections between points
$dijkstra = new \PHPAlgorithms\Dijkstra(function (\PHPAlgorithms\Dijkstra\Creator $creator) { $creator->addPoint('start'); $creator->addPoint('another one') ->addDoubleRelation($creator->getPoint(0), 10) ->addRelation($creator->addPoint(), 3); });
Generate paths from first point
[...] print_r($dijkstra->generate(0)); // \PHPAlgorithms\Dijkstra\Path object
Generate paths for all points
[...] print_r($dijkstra->generateAll()); // array of \PHPAlgorithms\Dijkstra\Path objects
Path object important parameters
[...] print_r($pathObj->distance); // how is the path long print_r($pathObj->nodes); // all points in this path
统计信息
- 总下载量: 191
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-01