SPeCS Packages Documentation
    Preparing search index...

    A collection of nodes from a given graph. All nodes have a common node type. If the nodes can be of any node type, the common type is BaseNode.

    Type Parameters

    Indexable

    • [index: number]: N

      Access the node at the given index.

    Index

    Accessors

    • get totalDegree(): number

      Returns the total degree of all nodes in the collection. Loop edges are counted twice.

      Returns number

      the total degree of this collection.

    • get totalDegreeWithoutLoops(): number

      Returns the total degree of all nodes in the collection. Loop edges are not counted.

      Returns number

      the total degree of this collection, excluding loop edges.

    Methods

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

      Parameters

      • index: number

        The index of the node to access.

      Returns N | undefined

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

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

      Parameters

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

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

      Returns boolean

      Whether all nodes in the collection satisfy the function.

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

      Type Parameters

      • T

      Parameters

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

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

      • thisArg: T

        The value to use as this when executing the function.

      Returns boolean

      Whether all nodes in the collection satisfy the function.

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

      Parameters

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

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

      Returns NodeCollection<N, D, S>

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

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

      Type Parameters

      • T

      Parameters

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

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

      • thisArg: T

        The value to use as this when executing the function.

      Returns NodeCollection<N, D, S>

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

    • Executes the provided function once for each node 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: N, i: number, eles: this) => void

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

      Returns void

    • Executes the provided function once for each node 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: N, i: number, eles: this) => void

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

      • thisArg: T

        The value to use as this when executing the function.

      Returns void

    • Parameters

      • id: string

      Returns N | undefined

      The node with the given id, or undefined if it is not in this collection.

    • Find the maximum value in a collection.

      Parameters

      • f: (ele: N, 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.

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

      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: N, 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.

      • thisArg: T

        The value to use as this when executing the function.

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

      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: N, 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.

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

      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: N, 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.

      • thisArg: T

        The value to use as this when executing the function.

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

      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 NodeCollection<N, D, S>

      A new collection containing the selected elements.

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

      Parameters

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

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

      Returns boolean

      Whether any node in the collection satisfies the function.

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

      Type Parameters

      • T

      Parameters

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

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

      • thisArg: T

        The value to use as this when executing the function.

      Returns boolean

      Whether any node 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: N, b: N) => number

        The comparison function to use for sorting.

      Returns NodeCollection<N, D, S>

      A new collection with the elements sorted.