Skip to main content
Version: 4.4

Class: CommitOrderCalculator#

core.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

Hierarchy#

  • CommitOrderCalculator

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:#

NameType
fromstring
tostring
weightnumber

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:#

NameType
hashstring

Returns: void

Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:49


discoverProperty#

discoverProperty(prop: EntityProperty<any>, entityName: string): void

Parameters:#

NameType
propEntityProperty<any>
entityNamestring

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:#

NameType
hashstring

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#

Privatevisit(node: Node): void

Visit a given node definition for reordering.

internal Highly performance-sensitive method.

Parameters:#

NameType
nodeNode

Returns: void

Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:102


visitOpenNode#

PrivatevisitOpenNode(node: Node, target: Node, edge: Edge): void

Visits all target's dependencies if in cycle with given node

Parameters:#

NameType
nodeNode
targetNode
edgeEdge

Returns: void

Defined in: packages/core/src/unit-of-work/CommitOrderCalculator.ts:124

Last updated on by renovate[bot]