import type { Dictionary, EntityProperty } from '../typings';
export declare const enum NodeState {
    NOT_VISITED = 0,
    IN_PROGRESS = 1,
    VISITED = 2
}
export interface Node {
    hash: string;
    state: NodeState;
    dependencies: Dictionary<Edge>;
}
export interface Edge {
    from: string;
    to: string;
    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 {
    /** Matrix of nodes, keys are provided hashes and values are the node definition objects. */
    private nodes;
    /** Volatile variable holding calculated nodes during sorting process. */
    private sortedNodeList;
    /**
     * Checks for node existence in graph.
     */
    hasNode(hash: string): boolean;
    /**
     * Adds a new node to the graph, assigning its hash.
     */
    addNode(hash: string): void;
    /**
     * Adds a new dependency (edge) to the graph using their hashes.
     */
    addDependency(from: string, to: string, weight: number): void;
    discoverProperty(prop: EntityProperty, entityName: string): 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(): string[];
    /**
     * 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;
}
