PHP Class Doctrine\Common\DataFixtures\Sorter\TopologicalSorter

This algorithm have a linear running time based on nodes (V) and dependency between the nodes (E), resulting in a computational complexity of O(V + E).
Author: Guilherme Blanco ([email protected])
Author: Roman Borschel ([email protected])
Datei anzeigen Open project: doctrine/data-fixtures Class Usage Examples

Public Methods

Method Description
__construct ( boolean $allowCyclicDependencies = true ) Construct TopologicalSorter object
addDependency ( string $fromHash, string $toHash ) : void Adds a new dependency (edge) to the graph using their hashes.
addNode ( string $hash, Doctrine\ORM\Mapping\ClassMetadata $node ) : void Adds a new node (vertex) to the graph, assigning its hash and value.
hasNode ( string $hash ) : boolean Checks the existence of a node in the graph.
sort ( ) : array Return a valid order list of all current nodes.

Private Methods

Method Description
visit ( Vertex $definition ) Visit a given node definition for reordering.

Method Details

__construct() public method

Construct TopologicalSorter object
public __construct ( boolean $allowCyclicDependencies = true )
$allowCyclicDependencies boolean

addDependency() public method

Adds a new dependency (edge) to the graph using their hashes.
public addDependency ( string $fromHash, string $toHash ) : void
$fromHash string
$toHash string
return void

addNode() public method

Adds a new node (vertex) to the graph, assigning its hash and value.
public addNode ( string $hash, Doctrine\ORM\Mapping\ClassMetadata $node ) : void
$hash string
$node Doctrine\ORM\Mapping\ClassMetadata
return void

hasNode() public method

Checks the existence of a node in the graph.
public hasNode ( string $hash ) : boolean
$hash string
return boolean

sort() public method

The desired topological sorting is the postorder of these searches. Note: Highly performance-sensitive method.
public sort ( ) : array
return array