import type { EntityProperty } from '../typings.js'; export declare const enum NodeState { NOT_VISITED = 0, IN_PROGRESS = 1, VISITED = 2 } type Hash = number; export interface Node { hash: Hash; state: NodeState; dependencies: Map; } export interface Edge { from: Hash; to: Hash; weight: number; } /** * 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 * @internal */ export declare class CommitOrderCalculator { #private; /** * Checks for node existence in graph. */ hasNode(hash: Hash): boolean; /** * Adds a new node to the graph, assigning its hash. */ addNode(hash: Hash): void; /** * Adds a new dependency (edge) to the graph using their hashes. */ addDependency(from: Hash, to: Hash, weight: number): void; discoverProperty(prop: EntityProperty, entityName: Hash): void; /** * 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. */ sort(): Hash[]; /** * Visit a given node definition for reordering. * * @internal Highly performance-sensitive method. */ private visit; /** * Visits all target's dependencies if in cycle with given node */ private visitOpenNode; } export {};