Access the node at the given index.
The edges that are adjacent to a node in this collection.
The nodes that are adjacent to a node in this collection.
The ancestors (parents, parents' parents, etc.) of the nodes in this collection.
The children of the nodes in this collection.
The descendants (children, children's children, etc.) of the nodes in this collection.
The edges coming into the nodes in this collection.
Whether this collection is empty.
The number of nodes in this collection.
The edges coming out of the nodes in this collection.
The parents of the nodes in this collection.
The predecessors of the nodes in this collection. This repeatedly follows the sources of incoming edges.
The successors of the nodes in this collection. This repeatedly follows the targets of outgoing edges.
Returns the total degree of all nodes in the collection. Loop edges are counted twice.
the total degree of this collection.
Returns the total degree of all nodes in the collection. Loop edges are not counted.
the total degree of this collection, excluding loop edges.
Checks if all nodes in this collection are compatible with a specific type. This is effectively a type guard function.
Whether the node is compatible with the given type.
Changes the functionality class of the nodes. This is only possible if the data and scratch data are compatible with the new class.
This is analogous to BaseNode.Class.as but for a collection of nodes.
The same collection, with the new functionality class.
The common ancestors of all nodes in the collection, starting with the closest and getting progressively farther.
Performs a diff comparison between this collection and another collection. You can think of the result as the added, removed, and kept elements to go from this collection to the other collection.
The other collection to compare with.
An object with three properties:
both
: A collection with the nodes that are in both collections. The type
of this collection is maintained.onlyLeft
: A collection with the nodes that are only in this collection. The
type of this collection is maintained.onlyRight
: A collection with the nodes that are only in the other collection.
The type of the other collection is maintained.The complement of this collection with respect to the universe of all nodes in the graph.
Returns whether the collection contains any of the nodes in the given collection.
The collection to check for.
Whether the collection contains any of the nodes in the given collection.
Returns the set difference of this collection with another collection. You may chain this method to remove multiple collections.
A new collection that consists of the nodes in this collection that are not in the other collection.
Retrieves the edges from the given nodes to this collection.
The node or collection of nodes to check for edges connected with this collection.
The edges from the given nodes to this collection.
Retrieves the edges from this collection to the given nodes.
The node or collection of nodes to check for edges connected with this collection.
The edges from this collection to the given nodes.
Retrieves the edges that connect this collection with the given nodes. Direction is not considered.
The node or collection of nodes to check for edges connected with this collection.
The edges that connect this collection with the given nodes.
Returns whether all nodes in the collection satisfy the provided function. Returns true for an empty collection.
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.
The function to test each node. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.
The value to use as this
when executing the function.
Whether all nodes in the collection satisfy the function.
Changes the functionality class of the nodes. Should only be used when it is known (but not statically provable) that all nodes 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 NodeCollection.allAre with NodeCollection.allAs.
The node collection, wrapped in the new functionality class.
LaraFlowError if any node 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 nodes that satisfy the provided function.
A new collection containing only the nodes that satisfy the function.
Returns a new collection containing only the nodes that satisfy the provided function.
The function to test each node. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.
The value to use as this
when executing the function.
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.
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.
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.
The value to use as this
when executing the function.
Returns the intersection of this collection with another collection. You may chain this method to intersect multiple collections.
A new collection containing the intersection of all nodes.
Find the maximum value in a collection.
An object with the maximum element and its value, or undefined if the collection is empty.
Find the maximum value in a collection.
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.
The value to use as this
when executing the function.
An object with the maximum element and its value, or undefined if the collection is empty.
Find the minimum value in a collection.
An object with the minimum element and its value, or undefined if the collection is empty.
Find the minimum value in a collection.
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.
The value to use as this
when executing the function.
An object with the minimum element and its value, or undefined if the collection is empty.
Returns whether the elements in the collection are the same as the elements in the other collection.
The other collection to compare with.
Whether the elements in the collection are the same as the elements in the other collection.
Get a subset of the elements in the collection based on specified indices.
Optional
start: numberAn 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.
Optional
end: numberAn 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.
A new collection containing the selected elements.
Returns whether any node in the collection satisfies the provided function. Returns false for an empty collection.
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.
The function to test each node. ele - The current element, i - The index of the current element, eles - The collection of elements being iterated.
The value to use as this
when executing the function.
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 new collection with the elements sorted.
Returns the symmetric difference of this collection with another collection. This collection consists of the nodes that are in either collection, but not in both.
If the rhs collection is a subtype of the lhs collection, the resulting collection will have the lhs type.
A new collection containing the symmetric difference of the two collections.
LaraFlowError if the other collection is from a different graph.
Returns the symmetric difference of this collection with another collection. This collection consists of the nodes that are in either collection, but not in both.
If the rhs collection is not a subtype of the lhs collection, the resulting collection will be downgraded to a BaseNode and must be casted to the desired type explicitly with NodeCollection.allAs.
A new collection containing the symmetric difference of the two collections.
LaraFlowError if the other collection is from a different graph.
Returns the union of this collection with another collection. You may chain this method to union multiple collections.
If the rhs collection is a subtype of the lhs collection, the resulting collection will have the lhs type.
A new collection containing the union of all nodes.
LaraFlowError if the other collection is from a different graph.
Returns the union of this collection with another collection. You may chain this method to union multiple collections.
If the rhs collection is not a subtype of the lhs collection, the resulting collection will be downgraded to a BaseNode and must be casted to the desired type explicitly with NodeCollection.allAs.
A new collection containing the union of all nodes.
LaraFlowError if the other collection is from a different graph.
Static
fromCreates a new collection from the given nodes. At least one node must be provided. For an empty collection, use BaseGraph.Class.emptyCollection.
A new collection containing the given nodes.
Static
fromCreates a new collection from the given cytoscape collection.
The cytoscape collection to create the collection from.
A new collection containing the nodes from the cytoscape collection.
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.