SkillAgentSearch skills...

Dijkstra

Dijkstra's algorithm in PHP

Install / Use

/learn @taniko/Dijkstra
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

Related Skills

View on GitHub
GitHub Stars20
CategoryDevelopment
Updated1y ago
Forks8

Languages

PHP

Security Score

75/100

Audited on Sep 13, 2024

No findings