almostanything / dependency-graph
该包最新版本(v1.0.0)没有可用的许可证信息。
简单的依赖图数据结构
v1.0.0
2015-02-04 09:30 UTC
Requires
- php: >=5.3.2
Requires (Dev)
- phpunit/phpunit: 4.4.*
This package is not auto-updated.
Last update: 2024-09-18 07:18:58 UTC
README
依赖图数据结构。
用法
基本用法
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());
依赖图可能是断开的,因此您可能需要提供一个DependencyGraph实例。
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');