PHPackages                             vertilia/algo-toposort - 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. [Search &amp; Filtering](/categories/search)
4. /
5. vertilia/algo-toposort

ActiveLibrary[Search &amp; Filtering](/categories/search)

vertilia/algo-toposort
======================

Topological sort algorithm

v1.0.0(2y ago)06BSD-2-ClausePHPPHP &gt;=7.4

Since Jul 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vertilia/algo-toposort)[ Packagist](https://packagist.org/packages/vertilia/algo-toposort)[ RSS](/packages/vertilia-algo-toposort/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

algo-toposort
=============

[](#algo-toposort)

[Topological sort](https://en.wikipedia.org/wiki/Topological_sorting) implementing [depth-first search](https://en.wikipedia.org/wiki/Depth-first_search) algorithm ([Tarjan](https://en.wikipedia.org/wiki/Robert_Tarjan) 1976).

Install
=======

[](#install)

```
composer require vertilia/algo-toposort
```

Usage
=====

[](#usage)

Example tree to sort topologically:

 ```
graph LR
    a --> b
    a --> d
    a --> c
    a --> e
    b --> d
    c --> d
    c --> e
    d --> e
```

      Loading Call with array passed in constructor:

```
$values = [
    'a' => ['b', 'd', 'c', 'e'],
    'b' => ['d'],
    'c' => ['d', 'e'],
    'd' => ['e'],
    'e' => [],
];

$a = new TopoSort($values);

$sorted = $a->sort();

print_r($sorted);
```

Call by forming initial array via `addNode()` calls:

```
$a = new TopoSort();

$a->addNode('a', ['b', 'd', 'c', 'e'])
    ->addNode('b', ['d']),
    ->addNode('c', ['d', 'e']),
    ->addNode('d', ['e']),
    ->addNode('e', []);

$sorted = $a->sort();

print_r($sorted);
```

Call by forming initial array via `addLink()` calls:

```
$a = new TopoSort();

$a->addLink('a', 'b')
    ->addLink('a', 'd'),
    ->addLink('a', 'c'),
    ->addLink('a', 'e'),
    ->addLink('b', 'd'),
    ->addLink('c', 'd'),
    ->addLink('c', 'e'),
    ->addLink('d', 'e');

$sorted = $a->sort();

print_r($sorted);
```

Output:

```
Array
(
    [0] => a
    [1] => c
    [2] => b
    [3] => d
    [4] => e
)

```

Resulting order:

 ```
graph LR
    a --> c
    c --> b
    b --> d
    d --> e
```

      Loading

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1020d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6480642?v=4)[Stas Trefilov](/maintainers/dotgit)[@dotgit](https://github.com/dotgit)

---

Top Contributors

[![dotgit](https://avatars.githubusercontent.com/u/6480642?v=4)](https://github.com/dotgit "dotgit (3 commits)")

---

Tags

searchsortdepth-firsttopotopological

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vertilia-algo-toposort/health.svg)

```
[![Health](https://phpackages.com/badges/vertilia-algo-toposort/health.svg)](https://phpackages.com/packages/vertilia-algo-toposort)
```

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k178.3M943](/packages/elasticsearch-elasticsearch)[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[solarium/solarium

PHP Solr client

93532.7M98](/packages/solarium-solarium)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)

PHPackages © 2026

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