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).
| Methods | ||
|---|---|---|
public
|
__construct()
|
# |
public
|
hasNode(string $hash): bool
|
# |
public
|
addNode(string $hash, ClassMetadata $node): void
|
# |
public
|
addDependency(string $fromHash, string $toHash, int $weight): void
|
# |
public
|
sort()
|
# |
private
|
visit(Vertex $vertex): void
|
# |
| Constants | ||
|---|---|---|
public
|
NOT_VISITED = VertexState::NOT_VISITED
|
# |
public
|
IN_PROGRESS = VertexState::IN_PROGRESS
|
# |
public
|
VISITED = VertexState::VISITED
|
# |
| Properties | |||
|---|---|---|---|
private
|
array<string, Vertex>
|
$nodeList = []
|
# |
private
|
|
$sortedNodeList = []
|
# |