Graphity for TypeScript 3.0.0
    Preparing search index...

    A list of edges of a graph, each with its source, target and edge index. Algorithms such as BackEdges.of and Biconnectivity.bridges return it.

    The edge at position p, in 0..count-1, is sourceNodes[p] -> targetNodes[p], and edgeIndices[p] is its edge index in the graph the algorithm ran on. The edge index finds the data of the edge in the caller's arrays indexed by edge index, without a search. Here, the back edges of the calls between the methods of a program are its recursive calls. names holds the names of the methods, and siteCount holds the number of call sites of each call, by edge index:

    const recursive = BackEdges.of(calls);
    for (let p = 0; p < recursive.count; p++) {
    const caller = recursive.sourceNodes[p];
    const callee = recursive.targetNodes[p];
    const edge = recursive.edgeIndices[p];
    console.log(`${names[caller]} -> ${names[callee]}: ${siteCount[edge]}`);
    }
    // parse -> parse: 2
    // format -> format: 1

    Each method that returns Edges says in which order the edges come. GraphBuilder.addEdges adds them to a graph under construction.

    Each of the three lists is an Int32Array that must not be modified (Java: an unmodifiable list). Instances are immutable.

    Memory: 12 bytes per edge.

    Index
    edgeIndices: Int32Array

    The edge index of each edge in the graph the algorithm ran on, by position (Java: edgeIndices()); not to be modified.

    Time: O(1).

    sourceNodes: Int32Array

    The source of each edge, by position (Java: sourceNodes()); not to be modified.

    Time: O(1).

    targetNodes: Int32Array

    The target of each edge, by position (Java: targetNodes()); not to be modified.

    Time: O(1).

    • get isEmpty(): boolean

      Whether there are no edges. Equivalent to count === 0 (Java: isEmpty()).

      Time: O(1).

      Returns boolean

    • Returns the edges of one type from an edge classification, in edge index order.

      Each call goes through every edge, however few have the type: call it once per type and keep the result.

      Time: O(nodeCount + edgeCount). Memory: 12 bytes per edge of the result.

      Parameters

      • edgeTypes: EdgeTypes

        the classification of the edges of a graph

      • type: EdgeType

        the edge type to collect

      Returns Edges

      the edges of type type

      Error if type is not one of EdgeType; this includes undefined and null (Java: NullPointerException for null)