CommitOrderCalculator
in package
CommitOrderCalculator implements topological sorting, which is an ordering algorithm for directed graphs (DG) and/or directed acyclic graphs (DAG) by using a depth-first searching (DFS) to traverse the graph built in memory.
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).
Table of Contents
Constants
- IN_PROGRESS = \Doctrine\ORM\Internal\CommitOrder\VertexState::IN_PROGRESS
- NOT_VISITED = \Doctrine\ORM\Internal\CommitOrder\VertexState::NOT_VISITED
- VISITED = \Doctrine\ORM\Internal\CommitOrder\VertexState::VISITED
Properties
- $nodeList : array<string, Vertex>
- Matrix of nodes (aka. vertex).
- $sortedNodeList : mixed
- Volatile variable holding calculated nodes during sorting process.
Methods
- addDependency() : void
- Adds a new dependency (edge) to the graph using their hashes.
- addNode() : void
- Adds a new node (vertex) to the graph, assigning its hash and value.
- hasNode() : bool
- Checks for node (vertex) existence in graph.
- sort() : mixed
- Return a valid order list of all current nodes.
- visit() : void
- Visit a given node definition for reordering.
Constants
IN_PROGRESS
public
mixed
IN_PROGRESS
= \Doctrine\ORM\Internal\CommitOrder\VertexState::IN_PROGRESS
Tags
NOT_VISITED
public
mixed
NOT_VISITED
= \Doctrine\ORM\Internal\CommitOrder\VertexState::NOT_VISITED
Tags
VISITED
public
mixed
VISITED
= \Doctrine\ORM\Internal\CommitOrder\VertexState::VISITED
Tags
Properties
$nodeList
Matrix of nodes (aka. vertex).
private
array<string, Vertex>
$nodeList
= []
Keys are provided hashes and values are the node definition objects.
$sortedNodeList
Volatile variable holding calculated nodes during sorting process.
private
mixed
$sortedNodeList
= []
Tags
Methods
addDependency()
Adds a new dependency (edge) to the graph using their hashes.
public
addDependency(string $fromHash, string $toHash, int $weight) : void
Parameters
- $fromHash : string
- $toHash : string
- $weight : int
addNode()
Adds a new node (vertex) to the graph, assigning its hash and value.
public
addNode(string $hash, ClassMetadata $node) : void
Parameters
- $hash : string
- $node : ClassMetadata
hasNode()
Checks for node (vertex) existence in graph.
public
hasNode(string $hash) : bool
Parameters
- $hash : string
Return values
boolsort()
Return a valid order list of all current nodes.
public
sort() : mixed
The desired topological sorting is the reverse post order of these searches.
Tags
visit()
Visit a given node definition for reordering.
private
visit(Vertex $vertex) : void
Parameters
- $vertex : Vertex