eZPublish  4.4
ezpTopologicalSort Class Reference

Sorts a series of dependencies in linear order (topological sort). More...

Public Member Functions

 __construct ($dependencies=array())
 Create a topological sort. More...
 
 sort ()
 Performs the topological linear ordering. More...
 

Protected Attributes

 $nodes = array()
 

Private Member Functions

 getRootNodes ()
 Returns a list of node objects that do not have parents. More...
 

Detailed Description

Sorts a series of dependencies in linear order (topological sort).

Constructor & Destructor Documentation

ezpTopologicalSort::__construct (   $dependencies = array())

Create a topological sort.

<?php $topologicalSort = new ezpTopologicalSort( array( 'a' => null, // a has no dependencies 'b' => 'a', // b depends on a 'd' => 'b', // d depends on b 'e' => array( 'd', 'c' ) // e depends on d and c ) ); ?>

Parameters
array$dependenciesArray of dependencies where the keys depends on the values. Values can either be a scalar or an array.

Member Function Documentation

ezpTopologicalSort::getRootNodes ( )
private

Returns a list of node objects that do not have parents.

Returns
array of node objects

Referenced by sort().

ezpTopologicalSort::sort ( )

Performs the topological linear ordering.

Returns
sorted array

Member Data Documentation

ezpTopologicalSort::$nodes = array()
protected

The documentation for this class was generated from the following file: