almostanything/dependency-graph

There is no license information available for the latest version (v1.0.0) of this package.

A simple dependency graph data structure

v1.0.0 2015-02-04 09:30 UTC

This package is not auto-updated.

Last update: 2024-09-18 07:18:58 UTC


README

A dependency graph data structure.

Usage

Basic Usage

use AlmostAnything\DependencyGraph\DependencyGraphNode as Node;

$jq = new Node('jquery.js');
$bs = new Node('bootstrap.js');
$dp = new Node('datepicker.js');

$jq->addChild($bs);
$dp->addParents($bs, $jq);

$graph = $jq->getGraph();             // returns an instance of DependencyGraph
var_dump($graph->topologicalSort());

Dependency Graphs can be disconnected so you may want to provide a DependencyGraph instance.

use AlmostAnything\DependencyGraph\DependencyGraphNode as Node;
use AlmostAnything\DependencyGraph\DependencyGraph as Graph;

$graph = new Graph();

$jq = new Node('jquery.js', $graph);
$pt = new Node('prototype.js', $graph);

$jq->addChild(new Node('bootstrap.js'));      // $graph will be automatically set on child
$pt->addChild(new Node('pt-typeahead.js');