#
Class: CommitOrderCalculatorcore.CommitOrderCalculator
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).
Based on https://github.com/doctrine/orm/blob/master/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php
#
Constructors#
constructor+ new CommitOrderCalculator(): CommitOrderCalculator
Returns: CommitOrderCalculator
#
Properties#
nodes• Private
nodes: Dictionary<Node>
Matrix of nodes, keys are provided hashes and values are the node definition objects.
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:34
#
sortedNodeList• Private
sortedNodeList: string[]
Volatile variable holding calculated nodes during sorting process.
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:37
#
Methods#
addDependencyâ–¸ addDependency(from
: string, to
: string, weight
: number): void
Adds a new dependency (edge) to the graph using their hashes.
#
Parameters:Name | Type |
---|---|
from | string |
to | string |
weight | number |
Returns: void
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:56
#
addNodeâ–¸ addNode(hash
: string): void
Adds a new node to the graph, assigning its hash.
#
Parameters:Name | Type |
---|---|
hash | string |
Returns: void
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:49
#
discoverPropertyâ–¸ discoverProperty(prop
: EntityProperty<any>, entityName
: string): void
#
Parameters:Name | Type |
---|---|
prop | EntityProperty<any> |
entityName | string |
Returns: void
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:60
#
hasNodeâ–¸ hasNode(hash
: string): boolean
Checks for node existence in graph.
#
Parameters:Name | Type |
---|---|
hash | string |
Returns: boolean
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:42
#
sortâ–¸ sort(): string[]
Return a valid order list of all current nodes. The desired topological sorting is the reverse post order of these searches.
internal
Highly performance-sensitive method.
Returns: string[]
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:81
#
visitâ–¸ Private
visit(node
: Node): void
Visit a given node definition for reordering.
internal
Highly performance-sensitive method.
#
Parameters:Name | Type |
---|---|
node | Node |
Returns: void
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:102
#
visitOpenNodeâ–¸ Private
visitOpenNode(node
: Node, target
: Node, edge
: Edge): void
Visits all target's dependencies if in cycle with given node
#
Parameters:Name | Type |
---|---|
node | Node |
target | Node |
edge | Edge |
Returns: void
Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:124