PHPackages                             xi/algorithm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xi/algorithm

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xi/algorithm
============

General purpose algorithms

113.0kPHP

Since Feb 8Pushed 12y ago17 watchersCompare

[ Source](https://github.com/xi-project/xi-algorithm)[ Packagist](https://packagist.org/packages/xi/algorithm)[ RSS](/packages/xi-algorithm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Xi Algorithm
============

[](#xi-algorithm)

A collection of miscellaneous algorithms.

Luhn
----

[](#luhn)

Usage:

```
use Xi\Algorithm\Luhn;

$luhn = new Luhn();
$luhn->generate(123); // 1230
```

Topological sort
----------------

[](#topological-sort)

Sorts the nodes of an acyclic graph so that if node X points to node Y then Y appears before X in the list. [Read more.](http://en.wikipedia.org/wiki/Topological_sorting)

Basically, it's useful for resolving a dependency graph.

Usage:

```
// A description of a graph:
$edges = array(
    'B' => array('C', 'D'),   // Node B points to nodes C and D
    'A' => array('B'),        // Node A points to node B
    'C' => array('D'),        // Node C points to node D
);

$nodesSorted = \Xi\Algorithm\TopologicalSort::apply($edges);
// $nodesSorted is now array('D', 'C', 'B', 'A')
```

Running the tests
-----------------

[](#running-the-tests)

No dependencies to other libraries exist, but in order to generate an autoloader first run

```
composer.phar install --dev

```

and then run the tests with

```
phpunit -c tests

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/426d650acd3c8b669bd59df3b385bd5d09c42a5c5085d86879d1dda17bbca544?d=identicon)[xi-project](/maintainers/xi-project)

---

Top Contributors

[![joonsp](https://avatars.githubusercontent.com/u/455369?v=4)](https://github.com/joonsp "joonsp (14 commits)")[![puppe0](https://avatars.githubusercontent.com/u/506220?v=4)](https://github.com/puppe0 "puppe0 (11 commits)")[![mpartel](https://avatars.githubusercontent.com/u/328952?v=4)](https://github.com/mpartel "mpartel (6 commits)")[![panunu](https://avatars.githubusercontent.com/u/1004036?v=4)](https://github.com/panunu "panunu (1 commits)")

### Embed Badge

![Health badge](/badges/xi-algorithm/health.svg)

```
[![Health](https://phpackages.com/badges/xi-algorithm/health.svg)](https://phpackages.com/packages/xi-algorithm)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
