Graphity for TypeScript 3.0.0
    Preparing search index...

    Variable TopOrderConst

    TopOrder: { of(graph: Graph): Int32Array } = ...

    The topological order of a DAG (directed acyclic graph), in which every node comes before its out-nodes.

    Uses a depth-first search, without recursion: TopOrder.of returns its reverse postorder. The search starts at the nodes in ascending order and takes the out-nodes of each node in ascending order, as DfsTraverser.run does, so a graph always gets the same order. TopOrderAndLevels returns another topological order, together with a level per node.

    A graph with a cycle has no topological order, and TopOrder.of rejects it; Graphs.isDag tests for a cycle, and Graphs.findCycle returns one. On a graph with cycles, Components.sccsOf puts each cycle into one SCC (strongly connected component) and numbers the SCCs in reverse topological order.

    Type Declaration

    • of: function
      • Returns the nodes of graph in topological order: for every edge u -> v, u comes before v.

        Time: O(nodeCount + edgeCount). Memory: 4 x nodeCount bytes for the result; while it runs, 2 bits per node and up to 8 x nodeCount bytes for the stack, which grows with the deepest path.

        Parameters

        • graph: Graph

          the DAG to sort

        Returns Int32Array

        the node IDs in topological order; a new array that must not be modified (Java: unmodifiable)

        Error if graph has a cycle, or if a depth-first path is longer than 2^30 - 5 nodes