opsminded/graph

A simple PHP graph library

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/opsminded/graph

v1.0.0 2025-12-30 16:30 UTC

This package is not auto-updated.

Last update: 2025-12-30 16:36:27 UTC


README

A small PHP graph library with basic graph structures and algorithms.

Quick start

Install with Composer:

composer require opsminded/graph

Example usage:

use Opsminded\Graph\UndirectedGraph;
use Opsminded\Graph\Node;
use Opsminded\Graph\Edge;
use Opsminded\Graph\Algorithms\BFS;

$g = new UndirectedGraph();
$a = new Node('a');
$b = new Node('b');
$g->addEdge(new Edge($a, $b));

$visited = [];
BFS::traverse($g, 'a', function($n) use (&$visited) {
    $visited[] = $n->getId();
});

print_r($visited);

See tests/ for a simple example test.

graph

PHP Graph library