A collection of edges from a given graph. All edges have a common edge type. If the edges can be of any edge type, the common type is BaseEdge.

Type Parameters

Indexable

  • [index: number]: E

    Access the edge at the given index.

Accessors

Methods

  • Access the edge at the given index. This is similar to indexing, but has undefined in the return type.

    Parameters

    • index: number

      The index of the edge to access.

    Returns undefined | E

    The edge at the given index, or undefined if it does not exist.

  • Returns whether all edges in the collection satisfy the provided function. Returns true for an empty collection.

    Parameters

    • f: ((ele: E, i: number, eles: this) => boolean)

      The function to test each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (ele, i, eles): boolean
        • Parameters

          • ele: E
          • i: number
          • eles: this

          Returns boolean

    Returns boolean

    Whether all edges in the collection satisfy the function.

  • Returns whether all edges in the collection satisfy the provided function. Returns true for an empty collection.

    Type Parameters

    • T

    Parameters

    • f: ((this: T, ele: E, i: number, eles: this) => boolean)

      The function to test each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (this, ele, i, eles): boolean
        • Parameters

          • this: T
          • ele: E
          • i: number
          • eles: this

          Returns boolean

    • thisArg: T

      The value to use as this when executing the function.

    Returns boolean

    Whether all edges in the collection satisfy the function.

  • Changes the functionality class of the edges. Should only be used when it is known (but not statically provable) that all edges are compatible with the new class. If not, an error will be thrown.

    It is bad practice to try and catch the error thrown by this function. For such cases, combine EdgeCollection.allAre with EdgeCollection.allAs.

    Type Parameters

    Parameters

    • EdgeType: Edge<D2, S2, E2>

      The edge type to change the functionality class into.

    • Optionalmessage: string | ((i: number) => string)

      The message to throw if the edge is not compatible with the type. May also be a function that takes the index of the first incompatible edge and returns a message.

    Returns EdgeCollection<E2, D2, S2>

    The edge collection, wrapped in the new functionality class.

    LaraFlowError if any edge is not compatible with the type. This error should be seen as a logic error and not catched.

  • Returns a new collection containing only the edges that satisfy the provided function.

    Parameters

    • f: ((ele: E, i: number, eles: this) => boolean)

      The function to test each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (ele, i, eles): boolean
        • Parameters

          • ele: E
          • i: number
          • eles: this

          Returns boolean

    Returns EdgeCollection<E, D, S>

    A new collection containing only the edges that satisfy the function.

  • Returns a new collection containing only the edges that satisfy the provided function.

    Type Parameters

    • T

    Parameters

    • f: ((this: T, ele: E, i: number, eles: this) => boolean)

      The function to test each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (this, ele, i, eles): boolean
        • Parameters

          • this: T
          • ele: E
          • i: number
          • eles: this

          Returns boolean

    • thisArg: T

      The value to use as this when executing the function.

    Returns EdgeCollection<E, D, S>

    A new collection containing only the edges that satisfy the function.

  • Executes the provided function once for each edge in the collection.

    Unline the analogous cytoscape method, this method does not support exiting early by returning false, due to the fact that a return false; would not be clear and intuitive for someone reading the code. As such, this function follows the behavior of the Array.prototype.forEach method.

    In the future, if that feature is really desirable, instead of returning false, the function could return an enum value that represents a control flow instruction. Until then, a for loop may be used.

    Parameters

    • f: ((ele: E, i: number, eles: this) => void)

      The function to execute for each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (ele, i, eles): void
        • Parameters

          • ele: E
          • i: number
          • eles: this

          Returns void

    Returns void

  • Executes the provided function once for each edge in the collection.

    Unline the analogous cytoscape method, this method does not support exiting early by returning false, due to the fact that a return false; would not be clear and intuitive for someone reading the code. As such, this function follows the behavior of the Array.prototype.forEach method.

    In the future, if that feature is really desirable, instead of returning false, the function could return an enum value that represents a control flow instruction. Until then, a for loop may be used.

    Type Parameters

    • T

    Parameters

    • f: ((this: T, ele: E, i: number, eles: this) => void)

      The function to execute for each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (this, ele, i, eles): void
        • Parameters

          • this: T
          • ele: E
          • i: number
          • eles: this

          Returns void

    • thisArg: T

      The value to use as this when executing the function.

    Returns void

  • Find the maximum value in a collection.

    Parameters

    • f: ((ele: E, i: number, eles: this) => number)

      The function that returns the value to compare. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (ele, i, eles): number
        • Parameters

          • ele: E
          • i: number
          • eles: this

          Returns number

    Returns undefined | {
        element: E;
        value: number;
    }

    An object with the maximum element and its value, or undefined if the collection is empty.

  • Find the maximum value in a collection.

    Type Parameters

    • T

    Parameters

    • f: ((this: T, ele: E, i: number, eles: this) => number)

      The function that returns the value to compare. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (this, ele, i, eles): number
        • Parameters

          • this: T
          • ele: E
          • i: number
          • eles: this

          Returns number

    • thisArg: T

      The value to use as this when executing the function.

    Returns undefined | {
        element: E;
        value: number;
    }

    An object with the maximum element and its value, or undefined if the collection is empty.

  • Find the minimum value in a collection.

    Parameters

    • f: ((ele: E, i: number, eles: this) => number)

      The function that returns the value to compare. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (ele, i, eles): number
        • Parameters

          • ele: E
          • i: number
          • eles: this

          Returns number

    Returns undefined | {
        element: E;
        value: number;
    }

    An object with the minimum element and its value, or undefined if the collection is empty.

  • Find the minimum value in a collection.

    Type Parameters

    • T

    Parameters

    • f: ((this: T, ele: E, i: number, eles: this) => number)

      The function that returns the value to compare. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (this, ele, i, eles): number
        • Parameters

          • this: T
          • ele: E
          • i: number
          • eles: this

          Returns number

    • thisArg: T

      The value to use as this when executing the function.

    Returns undefined | {
        element: E;
        value: number;
    }

    An object with the minimum element and its value, or undefined if the collection is empty.

  • Get a subset of the elements in the collection based on specified indices.

    Parameters

    • Optionalstart: number

      An integer that specifies where to start the selection. If omitted, the first element, with an index of 0, will be selected. Use negative numbers to select from the end of an array.

    • Optionalend: number

      An integer that specifies where to end the selection. If omitted, all elements from the start position and to the end of the array will be selected. Use negative numbers to select from the end of an array.

    Returns EdgeCollection<E, D, S>

    A new collection containing the selected elements.

  • Returns whether any edge in the collection satisfies the provided function. Returns false for an empty collection.

    Parameters

    • f: ((ele: E, i: number, eles: this) => boolean)

      The function to test each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (ele, i, eles): boolean
        • Parameters

          • ele: E
          • i: number
          • eles: this

          Returns boolean

    Returns boolean

    Whether any edge in the collection satisfies the function.

  • Returns whether any edge in the collection satisfies the provided function. Returns false for an empty collection.

    Type Parameters

    • T

    Parameters

    • f: ((this: T, ele: E, i: number, eles: this) => boolean)

      The function to test each edge. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.

        • (this, ele, i, eles): boolean
        • Parameters

          • this: T
          • ele: E
          • i: number
          • eles: this

          Returns boolean

    • thisArg: T

      The value to use as this when executing the function.

    Returns boolean

    Whether any edge in the collection satisfies the function.

  • Returns a collection with the elements sorted according to the given comparison function.

    Regarding the return value of the comparison function:

    • A negative value indicates that a should come before b.
    • A positive value indicates that a should come after b.
    • Zero or NaN indicates that a and b are considered equal.

    Parameters

    • f: ((a: E, b: E) => number)

      The comparison function to use for sorting.

        • (a, b): number
        • Parameters

          Returns number

    Returns EdgeCollection<E, D, S>

    A new collection with the elements sorted.