Download the PHP package fisharebest/algorithm without Composer
On this page you can find all versions of the php package fisharebest/algorithm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fisharebest/algorithm
More information about fisharebest/algorithm
Files in fisharebest/algorithm
Package algorithm
Short Description Implementation of standard algorithms in PHP.
License GPL-3.0-or-later
Homepage https://github.com/fisharebest/algorithm
Informations about the package algorithm
fisharebest/algorithm
General purpose algorithms in PHP
- Dijkstra
- Myers’ diff
- Connected/unconnected components of a graph
Installation
Install using composer.
Dijkstra
Dijkstra's algorithm finds the shortest path(s) between two nodes in a weighted, directed graph.
Graphs are specified as an array of edges, each with a cost. The example below is an undirected graph (i.e. if D→E is 9, then E→D is also 9.), because it is easy to understand and easy to draw. However, the algorithm works equally well for directed graphs, where links can be one-way only or have different costs in each direction.
Sample code for the above graph.
Myers’ diff
Find the difference between two sequences of tokens (characters, words, lines, etc.) using “An O(ND) Difference Algorithm and Its Variations” by Eugene W. Myers.
The output can be interpreted as either:
- A series of instructions to transform the first sequence into the second sequence.
- A list of matches (tokens that appear in both sequences) and mismatches (tokens that appear in just one sequence).
Connected components
A depth-first search of a graph to find isolated groups of nodes.
Sample code for the above graph