• Parameters

    • directedEdges: [number, number][]

      an array of directed edges where each edge contains two vertex indices with the direction going from index 0 towards 1

    Returns number[]

    an ordering of the vertices from the edges provided, or undefined if a cycle is detected.

    Description

    Perform a topological sort on a directed acyclic graph. If a cycle exists, this method will return undefined.