PHPackages                             mathieuviossat/fibonacci-heap - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. mathieuviossat/fibonacci-heap

ActiveLibrary[Queues &amp; Workers](/categories/queues)

mathieuviossat/fibonacci-heap
=============================

PHP implementation of the Fibonacci heap

v1.0.1(10y ago)51441MITPHPPHP &gt;=5.3.0

Since Sep 3Pushed 10y ago1 watchersCompare

[ Source](https://github.com/viossat/fibonacci-heap)[ Packagist](https://packagist.org/packages/mathieuviossat/fibonacci-heap)[ Docs](https://github.com/MathieuViossat/fibonacci-heap)[ RSS](/packages/mathieuviossat-fibonacci-heap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Fibonacci heap
==============

[](#fibonacci-heap)

The Fibonacci heap is a heap data structure with the best amortized running time. It was developed by Michael L. Fredman and Robert E. Tarjan in 1984. The running time of Dijkstra's algorithm can be improved to O(|E| + |V| log |V|) by using a Fibonacci heap.

Installation
------------

[](#installation)

```
composer require mathieuviossat/fibonacci-heap

```

```
{
    "require": {
        "mathieuviossat/fibonacci-heap": "~1.0.0"
    }
}
```

Example
-------

[](#example)

```
use MathieuViossat\Util\FibonacciHeap;

$movies = new FibonacciHeap();

$movies->insert(4, 'The Phantom Menace');
$movies->insert(5, 'Attack of the Clones');
$movies->insert(6, 'Revenge of the Sith');
$movies->insert(1, 'A New Hope');
$movies->insert(2, 'The Empire Strikes Back');
$movies->insert(3, 'Return of the Jedi');
$movies->insert(7, 'The Force Awakens');

while ($movie = $movies->extractMin())
    echo $movie->getKey() . ' - ' . $movie->getData() . PHP_EOL;
```

Methods
-------

[](#methods)

#### minimum() : FibonacciHeapElement

[](#minimum--fibonacciheapelement)

Returns the element with the lowest key, or null if the heap is empty.
Complexity: Θ(1)

#### insert(int|float $key, mixed $data) : FibonacciHeapElement

[](#insertintfloat-key-mixed-data--fibonacciheapelement)

Inserts $data with the priority $key in the heap and return the element.
Complexity: Θ(1)

#### extractMin() : FibonacciHeapElement

[](#extractmin--fibonacciheapelement)

Deletes the element with the lowest priority from the heap and return it.
Amortized complexity: O(log n)

#### decreaseKey(FibonacciHeapElement $element, int|float $key) : void

[](#decreasekeyfibonacciheapelement-element-intfloat-key--void)

Replaces $element's key by $key. $key must be lower than the old key.
Amortized complexity: Θ(1)

#### delete(FibonacciHeapElement $element) : void

[](#deletefibonacciheapelement-element--void)

Deletes $element from the heap.
Amortized complexity: O(log n)

#### merge(FibonacciHeap $other) : void

[](#mergefibonacciheap-other--void)

Merges the both heaps. I recommend to only use one of them after that.
Complexity: Θ(1)

#### isEmpty() : bool

[](#isempty--bool)

Retuns true if the heap is empty, false otherwise.
Complexity: Θ(1)

#### size() / count() / count($heap) : int

[](#size--count--countheap--int)

Retuns the number of elements in the heap.
Complexity: Θ(1)

#### clear() : void

[](#clear--void)

Removes all elements from the heap.
Complexity: Θ(1)

License
-------

[](#license)

This library is published under [The MIT License](http://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Every ~28 days

Total

2

Last Release

3881d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cb1917505dcd11c319b7407cdafed34d41509b57fd8fd6a3be528d86cb96d14?d=identicon)[viossat](/maintainers/viossat)

---

Top Contributors

[![viossat](https://avatars.githubusercontent.com/u/3019820?v=4)](https://github.com/viossat "viossat (2 commits)")

---

Tags

queuelisttreebinaryheappriorityfibonaccibinomial

### Embed Badge

![Health badge](/badges/mathieuviossat-fibonacci-heap/health.svg)

```
[![Health](https://phpackages.com/badges/mathieuviossat-fibonacci-heap/health.svg)](https://phpackages.com/packages/mathieuviossat-fibonacci-heap)
```

###  Alternatives

[php-amqplib/php-amqplib

Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.

4.6k125.3M879](/packages/php-amqplib-php-amqplib)[ramsey/collection

A PHP library for representing and manipulating collections.

1.2k486.0M69](/packages/ramsey-collection)[queue-interop/queue-interop

Promoting the interoperability of MQs objects. Based on Java JMS

48130.5M87](/packages/queue-interop-queue-interop)[phootwork/collection

The phootwork library fills gaps in the php language and provides better solutions than the existing ones php offers.

3924.8M15](/packages/phootwork-collection)[tarantool/queue

PHP bindings for Tarantool Queue.

64136.2k4](/packages/tarantool-queue)[traderinteractive/mongo-queue

Message queue using MongoDB as a backend

4617.5k](/packages/traderinteractive-mongo-queue)

PHPackages © 2026

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