Graphity for TypeScript 3.0.0
    Preparing search index...

    A mapping from the edge indices of one graph to those of another, to carry data on edges over to a subgraph, a renumbered graph or the transposed graph.

    get(e) is the edge index that edge e maps to, or -1 if edge e is not mapped. The factories return mappings from a new graph to an old one. These map each new edge to the edge it comes from. Graphs.edgeMapping derives one from the NodeMapping of a subgraph or a renumbering, and leaves a new edge without a counterpart in the old graph unmapped. Graphs.transposedEdgeMapping maps each edge of the transposed graph to the edge it reverses.

    EdgeMapping.gather carries data on the old edges over to the new ones. Here, siteCount holds the number of call sites of each call by edge index of calls, and the subgraph loading from the example at NodeMapping takes these counts along:

    const loadingSiteCount = Graphs.edgeMapping(loading, calls, newToOld).gather(
    siteCount,
    );
    // 1 for load -> parse and for load -> read, 2 for parse -> parse

    EdgeMapping.inverted returns the mapping from old to new, and EdgeMapping.compose chains two mappings.

    Instances are immutable.

    Memory: 4 x indexCount bytes.

    Hierarchy (View Summary)

    Index
    • get indexCount(): number

      The number of indices this mapping maps from, mapped or not.

      It is the length of the arrays that gather returns and that reduce takes.

      Time: O(1).

      Returns number

    • get isPartial(): boolean

      Whether some index is not mapped. Equivalent to mappedCount < indexCount.

      Time: O(1).

      Returns boolean

    • get mappedCount(): number

      The number of indices that are mapped; in a partition, the number of indices that belong to a group.

      Time: O(1).

      Returns number

    • Returns the mapping that applies inner first and then this mapping.

      If inner maps the edges of a graph A to those of B, and this mapping maps B to C, the result maps A to C. An edge is not mapped in the result if inner does not map it, or if this mapping does not map the edge that inner maps it to.

      Time: O(inner.indexCount). Memory: 4 x inner.indexCount bytes for the result.

      Parameters

      Returns EdgeMapping

      the composed mapping

      RangeError if inner maps an edge to an edge index outside 0..indexCount-1

    • Returns values renumbered by this mapping: the value at position i of the result is values[get(i)], or 0 if edge i is not mapped. The result is a typed array of the type of values (Java: the int[], long[] and double[] forms; here any typed array).

      For a mapping from new to old edge indices, as the factories return it, this carries data on the edges of the old graph over to the new graph. The form with newValues does the same for values of any kind.

      Time: O(indexCount). Memory: one element per index for the result: 4 x indexCount bytes for an Int32Array, 8 x indexCount bytes for a Float64Array or a BigInt64Array.

      Type Parameters

      Parameters

      • values: A

        the value of each edge of the graph that this mapping maps to

      Returns A

      the renumbered values, of length IndexMapping.indexCount

      RangeError if an edge maps to an edge index outside values

    • Writes values renumbered by this mapping into newValues, for values of any kind (Java: the T[] form). The second argument selects this form, as in Java's overload resolution: the values may be in any array-like, also in a typed array.

      newValues[i] becomes values[get(i)], and stays as it is if edge i is not mapped. References are copied, not the objects. If an error is thrown, newValues may be partly written.

      Time: O(indexCount).

      Type Parameters

      • T

      Parameters

      • values: ArrayLike<T>

        the value of each edge of the graph that this mapping maps to

      • newValues: T[]

        receives the renumbered values; length IndexMapping.indexCount, and not the same array as values

      Returns void

      Error if newValues.length !== indexCount, or both are the same array

      RangeError if an edge maps to an edge index outside values

    • Returns the index that id maps to, or -1 if id is not mapped.

      In a partition, it is the group of id.

      Time: O(1).

      Parameters

      • id: number

        index in 0..indexCount-1

      Returns number

      index that id maps to, or -1

      RangeError if id is out of range

    • Returns the inverse mapping, which maps get(e) back to e.

      The inverse maps the targetCount edges of the graph that this mapping maps to; an edge that no edge maps to is not mapped, and the inverse is then partial. For a mapping from new to old edge indices, as the factories return it, targetCount is the edge count of the old graph, and the inverse gives the new edge index of an old edge: newToOld.inverted(oldGraph.edgeCount).get(oldEdge).

      Time: O(indexCount + targetCount). Memory: 4 x targetCount bytes for the result.

      Parameters

      • targetCount: number

        the edge count of the graph that this mapping maps to

      Returns EdgeMapping

      the inverse mapping, with an index count of targetCount

      Error if targetCount is not an integer, is negative or larger than 2^31 - 9, or two edges map to the same edge

      RangeError if an edge maps to targetCount or more

    • Returns whether id is mapped. Equivalent to get(id) !== -1.

      Time: O(1).

      Parameters

      • id: number

        index in 0..indexCount-1

      Returns boolean

      true if id is mapped

      RangeError if id is out of range