Gliph
Gliph is a graph library for PHP. It provides graph building blocks and datastructures for use by other PHP applications. It is designed for use with in-memory graphs, not for interaction with a graph database like Cayley or Neo4J (though it could be used to facilitate such connection).
Gliph aims for both sane interfaces and as performant an implementation as userspace PHP allows.
This does require knowing enough about graphs to know what type is appropriate for your use case, but we are aiming to provide helpers that simplify those choices.
Quickstart
Working with gliph is easy: pick a graph implementation, then add edges and vertices as needed. ()Note that gliph currently supports only object vertices, though this limitation may be loosened in future releases)
<?php
use Gliph\Graph\DirectedAdjacencyList;
class Vertex {
public $val;
public function __construct($val) {
$this->val = $val;
}
}
$vertices = array(
'a' => new Vertex('a'),
'b' => new Vertex('b'),
'c' => new Vertex('c'),
'd' => new Vertex('d'),
'e' => new Vertex('e'),
'f' => new Vertex('f'),
);
$g = new DirectedAdjacencyList();
foreach ($vertices as $vertex) {
$g->ensureVertex($vertex);
}
$g->ensureArc($vertices['a'], $vertices['b']);
$g->ensureArc($vertices['b'], $vertices['c']);
$g->ensureArc($vertices['a'], $vertices['c']);
$g->ensureArc($vertices['d'], $vertices['a']);
$g->ensureArc($vertices['d'], $vertices['e']);
This would create the following directed graph:



