Graphity for TypeScript 3.0.0
    Preparing search index...

    Variable BackEdgesConst

    BackEdges: { of(graph: Graph): Edges } = ...

    The back edges of a graph: the edges that a depth-first search finds pointing back to a node on its current path, self-loops included.

    Every cycle contains a back edge, so a graph without back edges is a DAG (directed acyclic graph), and removing the back edges of a graph leaves a DAG. They form a feedback arc set, though not in general a smallest one.

    Uses the depth-first search of EdgeTypes.of, without recursion: BackEdges.of finds the edges that EdgeTypes classifies as EdgeType.BACK, without classifying the others.

    Type Declaration

    • of: function
      • Returns the back edges of graph, in the order in which the search finds them.

        Unlike the other results that list edges, they do not come in edge index order. For that order, use Edges.of(EdgeTypes.of(graph), EdgeType.BACK): the same edges, at the cost of classifying every edge first.

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

        Parameters

        • graph: Graph

          the graph to search

        Returns Edges

        the back edges with their edge indices

        Error if a depth-first path is longer than 2^30 - 5 nodes