nodes -> Cy.NodeCollection a collection of one or more nodes

The output is a collection of node elements OR single node.

interface NodeCollection {
    -: CollectionBuildingDifferenceFunc;
    !: CollectionBuildingDifferenceFunc;
    .: CollectionBuildingIntersectionFunc;
    (-): CollectionSymmetricDifferenceFunc;
    (+): CollectionSymmetricDifferenceFunc;
    \: CollectionBuildingDifferenceFunc;
    &: CollectionBuildingIntersectionFunc;
    ^: CollectionSymmetricDifferenceFunc;
    +: CollectionBuildingUnionFunc;
    |: CollectionBuildingUnionFunc;
    add: CollectionBuildingUnionFunc;
    and: CollectionBuildingIntersectionFunc;
    difference: CollectionBuildingDifferenceFunc;
    intersect: CollectionBuildingIntersectionFunc;
    intersection: CollectionBuildingIntersectionFunc;
    length: number;
    n: CollectionBuildingIntersectionFunc;
    not: CollectionBuildingDifferenceFunc;
    or: CollectionBuildingUnionFunc;
    relativeComplement: CollectionBuildingDifferenceFunc;
    subtract: CollectionBuildingDifferenceFunc;
    symdiff: CollectionSymmetricDifferenceFunc;
    symmetricDifference: CollectionSymmetricDifferenceFunc;
    u: CollectionBuildingUnionFunc;
    union: CollectionBuildingUnionFunc;
    xor: CollectionSymmetricDifferenceFunc;
    [iterator](): Iterator<NodeSingular, any, any>;
    $id(id: string): NodeSingular;
    abscomp(): CollectionReturnValue;
    absoluteComplement(): CollectionReturnValue;
    addClass(classes: ClassNames): this;
    addListener(events: string, selector: string, handler: EventHandler): this;
    addListener(events: string, handler: EventHandler): this;
    allAre(selector: string): boolean;
    allAreNeighbors(eles: CollectionArgument): boolean;
    allAreNeighbours(eles: CollectionArgument): boolean;
    ancestors(selector?: string): cytoscape.NodeCollection;
    animate(options: ElementAnimateOptionPos | ElementAnimateOptionRen, params?: ElementAnimateOptionsBase): this;
    anySame(eles: CollectionArgument): boolean;
    aStar(options: SearchAStarOptions): SearchAStarResult;
    attr(name?: string): any;
    attr(name: string, value: any): this;
    attr(obj: any): this;
    bellmanFord(options: SearchBellmanFordOptions): SearchBellmanFordResult;
    betweennessCentrality(options: SearchBetweennessOptions): SearchBetweennessResult;
    bfs(options: SearchFirstOptions): SearchFirstResult;
    bind(events: string, selector: string, handler: EventHandler): this;
    bind(events: string, handler: EventHandler): this;
    boundingbox(options?: BoundingBoxOptions): BoundingBox12 & BoundingBoxWH;
    boundingBox(options?: BoundingBoxOptions): BoundingBox12 & BoundingBoxWH;
    breadthFirstSearch(options: SearchFirstOptions): SearchFirstResult;
    children(selector?: string): cytoscape.NodeCollection;
    classes(classes: ClassNames): this;
    classes(classes: undefined | ClassNames): string[] | cytoscape.NodeCollection;
    classes(): string[];
    clearQueue(): this;
    clone(): CollectionReturnValue;
    closedNeighborhood(selector?: string): CollectionReturnValue;
    closenessCentrality(options: SearchClosenessCentralityOptions): number;
    closenessCentralityNormalized(options: SearchClosenessCentralityNormalizedOptions): SearchDegreeCentralityNormalizedResultUndirected | SearchDegreeCentralityNormalizedResultDirected;
    commonAncestors(selector?: string): cytoscape.NodeCollection;
    complement(): CollectionReturnValue;
    components(): CollectionReturnValue[];
    connectedEdges(selector?: string): cytoscape.EdgeCollection;
    contains(eles: CollectionArgument): boolean;
    copy(): CollectionReturnValue;
    createLayout(options: LayoutOptions): Layouts;
    css(name: string, value: any): this;
    css(name: string): any;
    css(obj: object): this;
    css(): {
        [index: string]: any;
    };
    data(name?: string): any;
    data(name: string, value: any): this;
    data(obj: any): this;
    degreeCentrality(options: SearchDegreeCentralityOptions): SearchDegreeCentralityResultUndirected | SearchDegreeCentralityResultDirected;
    degreeCentralityNormalized(options: SearchDegreeCentralityNormalizedOptions): SearchDegreeCentralityNormalizedResultUndirected | SearchDegreeCentralityNormalizedResultDirected;
    delay(duration: number, complete?: (() => void)): this;
    depthFirstSearch(options: SearchFirstOptions): SearchFirstResult;
    descendants(selector?: string): cytoscape.NodeCollection;
    deselect(): this;
    dfs(options: SearchFirstOptions): SearchFirstResult;
    diff(selector: string | CollectionArgument): {
        both: CollectionReturnValue;
        left: CollectionReturnValue;
        right: CollectionReturnValue;
    };
    dijkstra(options: SearchDijkstraOptions): SearchDijkstraResult;
    each(each: ((ele: NodeSingular, i: number, eles: this) => boolean | void), thisArg?: any): this;
    edges(selector?: string): cytoscape.EdgeCollection;
    edgesTo(eles: string | CollectionArgument): cytoscape.EdgeCollection;
    edgesWith(eles: string | CollectionArgument): cytoscape.EdgeCollection;
    emit(events: string, extra?: unknown[]): this;
    empty(): boolean;
    eq(index: number): NodeSingular;
    every(test: ((ele: CollectionArgument, i: number, eles: CollectionArgument) => boolean), thisArg?: any): boolean;
    filter(selector: string | ((ele: NodeSingular, i: number, eles: CollectionArgument) => boolean)): CollectionReturnValue;
    first(): NodeSingular;
    flashClass(classes: ClassNames, duration?: number): this;
    floydWarshall(options: SearchFloydWarshallOptions): SearchFloydWarshallResult;
    forEach(each: ((ele: NodeSingular, i: number, eles: this) => boolean | void), thisArg?: any): this;
    getElementById(id: string): NodeSingular;
    grabify(): this;
    has(eles: CollectionArgument): boolean;
    hopcroftTarjanBiconnected(): {
        components: CollectionReturnValue;
        cut: cytoscape.NodeCollection;
    };
    hopcroftTarjanBiconnectedComponents(): {
        components: CollectionReturnValue;
        cut: cytoscape.NodeCollection;
    };
    htb(): {
        components: CollectionReturnValue;
        cut: cytoscape.NodeCollection;
    };
    htbc(): {
        components: CollectionReturnValue;
        cut: cytoscape.NodeCollection;
    };
    incomers(selector?: string): CollectionReturnValue;
    is(selector: string): boolean;
    jsons(): string[];
    kargerStein(): {
        components: CollectionReturnValue;
        cut: cytoscape.EdgeCollection;
        partitionFirst: cytoscape.NodeCollection;
        partitionSecond: cytoscape.NodeCollection;
    };
    kruskal(handler: ((edge: cytoscape.EdgeCollection) => number)): CollectionReturnValue;
    last(): NodeSingular;
    layout(options: LayoutOptions): Layouts;
    layoutPositions(layout: string, options: LayoutPositionOptions, handler: ElementPositionFunction): void;
    leaves(selector?: string): cytoscape.NodeCollection;
    listen(events: string, selector: string, handler: EventHandler): this;
    listen(events: string, handler: EventHandler): this;
    lock(): this;
    makeLayout(options: LayoutOptions): Layouts;
    map<T>(fn: ((ele: NodeSingular, i: number, eles: CollectionArgument) => T), thisArg?: any): T[];
    max<T>(fn: ((ele: NodeSingular, i: number, eles: CollectionArgument) => T), thisArg?: any): {
        ele: SingularElementReturnValue;
        value: T;
    };
    maxDegree(includeLoops: boolean): number;
    maxIndegree(includeLoops: boolean): number;
    maxOutdegree(includeLoops: boolean): number;
    merge(eles: string | CollectionArgument): this;
    min<T>(fn: ((ele: NodeSingular, i: number, eles: CollectionArgument) => T), thisArg?: any): {
        ele: SingularElementReturnValue;
        value: T;
    };
    minDegree(includeLoops: boolean): number;
    minIndegree(includeLoops: boolean): number;
    minOutdegree(includeLoops: boolean): number;
    modelPositions(handler: Position | ElementPositionFunction): this;
    move(location: {
        source?: string;
        target?: string;
    }): cytoscape.EdgeCollection;
    move(location: {
        parent: null | string;
    }): cytoscape.NodeCollection;
    neighborhood(selector?: string): CollectionReturnValue;
    nodes(selector?: string): cytoscape.NodeCollection;
    nonempty(): boolean;
    nonorphans(selector?: string): cytoscape.NodeCollection;
    off(events: string, selector?: string, handler?: EventHandler): this;
    on(events: string, selector: string, handler: EventHandler): this;
    on(events: string, handler: EventHandler): this;
    once(events: string, selector: string, data: any, handler: EventHandler): this;
    once(events: string, selector: string, handler: EventHandler): this;
    once(events: string, handler: EventHandler): this;
    one(events: string, selector: string, data: any, handler: EventHandler): this;
    one(events: string, selector: string, handler: EventHandler): this;
    one(events: string, handler: EventHandler): this;
    openNeighborhood(selector?: string): CollectionReturnValue;
    orphans(selector?: string): cytoscape.NodeCollection;
    outgoers(selector?: string): CollectionReturnValue;
    pageRank(options: SearchPageRankOptions): SearchPageRankResult;
    parent(selector?: string): cytoscape.NodeCollection;
    parents(selector?: string): cytoscape.NodeCollection;
    points(handler: Position | ElementPositionFunction): this;
    pon(events: string, selector?: string): Promise<EventHandler>;
    positions(handler: Position | ElementPositionFunction): this;
    predecessors(selector?: string): CollectionReturnValue;
    promiseOn(events: string, selector?: string): Promise<EventHandler>;
    reduce<T>(fn: ((prevVal: T, ele: NodeSingular, i: number, eles: CollectionArgument) => T), initialValue: T): T;
    remove(): CollectionReturnValue;
    removeAllListeners(): this;
    removeAttr(names?: string): CollectionReturnValue;
    removeClass(classes: ClassNames): this;
    removeData(names?: string): CollectionReturnValue;
    removeListener(events: string, selector?: string, handler?: EventHandler): this;
    removeStyle(names?: string): this;
    renderedBoundingbox(options?: BoundingBoxOptions): BoundingBox12 & BoundingBoxWH;
    renderedBoundingBox(options?: BoundingBoxOptions): BoundingBox12 & BoundingBoxWH;
    restore(): CollectionReturnValue;
    roots(selector?: string): cytoscape.NodeCollection;
    same(eles: CollectionArgument): boolean;
    select(): this;
    selectify(): this;
    shift(dimension: PositionDimension, value?: number): this;
    shift(pos: Position): this;
    siblings(selector?: string): cytoscape.NodeCollection;
    size(): number;
    slice(start?: number, end?: number): this;
    some(test: ((ele: CollectionArgument, i: number, eles: CollectionArgument) => boolean), thisArg?: any): boolean;
    sort(sort: ((ele1: NodeSingular, ele2: NodeSingular) => number)): CollectionReturnValue;
    stop(clearQueue?: boolean, jumpToEnd?: boolean): this;
    style(name: string, value: any): this;
    style(name: string): any;
    style(obj: object): this;
    style(): {
        [index: string]: any;
    };
    successors(selector?: string): CollectionReturnValue;
    tarjanStronglyConnected(): {
        components: CollectionReturnValue;
        cut: cytoscape.EdgeCollection;
    };
    tarjanStronglyConnectedComponents(): {
        components: CollectionReturnValue;
        cut: cytoscape.EdgeCollection;
    };
    toArray(): NodeSingular[];
    toggleClass(classes: ClassNames, toggle?: boolean): this;
    totalDegree(includeLoops: boolean): number;
    trigger(events: string, extra?: unknown[]): this;
    tsc(): {
        components: CollectionReturnValue;
        cut: cytoscape.EdgeCollection;
    };
    tscc(): {
        components: CollectionReturnValue;
        cut: cytoscape.EdgeCollection;
    };
    unbind(events: string, selector?: string, handler?: EventHandler): this;
    ungrabify(): this;
    unlisten(events: string, selector?: string, handler?: EventHandler): this;
    unlock(): this;
    unmerge(eles: string | CollectionArgument): this;
    unselect(): this;
    unselectify(): this;
}

Hierarchy (view full)

Properties

Methods

Properties

Get a new collection, resulting from the collection without some specified elements. http://js.cytoscape.org/#eles.difference

Get the elements in both this collection and another specified collection. http://js.cytoscape.org/#eles.intersection

length: number

Get the number of elements in the collection.

Get the elements that are in the calling collection or the passed collection but not in both. http://js.cytoscape.org/#eles.symmetricDifference

Get a new collection, resulting from adding the collection with another one http://js.cytoscape.org/#eles.union

Methods

  • Get the closed neighbourhood of the elements.

    The neighbourhood returned by this function is a bit different than the traditional definition of a "neighbourhood": This returned neighbourhood includes the edges connecting the collection to the neighbourhood. This gives you more flexibility. A closed neighbourhood is one that does include the original set of elements.

    Parameters

    • Optionalselector: string

      [optional] An optional selector that is used to filter the resultant collection.

    Returns CollectionReturnValue

  • Iterate over the elements in the collection using an implementation like the native array function namesake.

    This function behaves like Array.prototype.forEach() with minor changes for convenience: You can exit the iteration early by returning false in the iterating function. The Array.prototype.forEach() implementation does not support this, but it is included anyway on account of its utility.

    Parameters

    • each: ((ele: NodeSingular, i: number, eles: this) => boolean | void)

      The function executed each iteration. ele - The current element. i - The index of the current element. eles - The collection of elements being iterated.

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

          Returns boolean | void

    • OptionalthisArg: any

      [optional] The value for this within the iterating function.

    Returns this

  • Determine whether all elements in this collection satisfy the specified test function.

    Parameters

    • test: ((ele: CollectionArgument, i: number, eles: CollectionArgument) => boolean)

      The test function that returns truthy values for elements that satisfy the test and falsey values for elements that do not satisfy the test. ele - The current element. i - The index of the current element. eles - The collection of elements being tested.

    • OptionalthisArg: any

      [optional] The value for this within the test function.

    Returns boolean

  • Perform a in-place merge of the given elements into the calling collection.

    Parameters

    • eles: string | CollectionArgument

      The elements to merge in-place or a selector representing the elements to merge. All elements in the graph matching the selector are used as the passed collection.

      This function modifies the calling collection instead of returning a new one. Use of this function should be considered for performance in some cases, but otherwise should be avoided. Consider using eles.union() instead. Use this function only on new collections that you create yourself, using cy.collection(). This ensures that you do not unintentionally modify another collection.

      Examples With a collection:

    Returns this

    var col = cy.collection(); // new, empty collection
    var j = cy.$('#j');
    var e = cy.$('#e');
    col.merge( j ).merge( e );

    With a selector:
    var col = cy.collection(); // new, empty collection
    col.merge('#j').merge('#e');
  • Get the open neighbourhood of the elements.

    The neighbourhood returned by this function is a bit different than the traditional definition of a "neighbourhood": This returned neighbourhood includes the edges connecting the collection to the neighbourhood. This gives you more flexibility. An open neighbourhood is one that does not include the original set of elements. If unspecified, a neighbourhood is open by default.

    Parameters

    • Optionalselector: string

      [optional] An optional selector that is used to filter the resultant collection.

    Returns CollectionReturnValue

  • Get the open neighbourhood of the elements.

    The neighbourhood returned by this function is a bit different than the traditional definition of a "neighbourhood": This returned neighbourhood includes the edges connecting the collection to the neighbourhood. This gives you more flexibility. An open neighbourhood is one that does not include the original set of elements. If unspecified, a neighbourhood is open by default.

    Parameters

    • Optionalselector: string

      [optional] An optional selector that is used to filter the resultant collection.

    Returns CollectionReturnValue

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

    Parameters

    • Optionalstart: number

      [optional] An integer that specifies where to start the selection. The first element has an index of 0. Use negative numbers to select from the end of an array.

    • Optionalend: number

      [optional] 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 this

  • Determine whether any element in this collection satisfies the specified test function.

    Parameters

    • test: ((ele: CollectionArgument, i: number, eles: CollectionArgument) => boolean)

      The test function that returns truthy values for elements that satisfy the test and falsey values for elements that do not satisfy the test. ele - The current element. i - The index of the current element. eles - The collection of elements being tested.

    • OptionalthisArg: any

      [optional] The value for this within the test function.

    Returns boolean

  • Perform an in-place operation on the calling collection to remove the given elements.

    Parameters

    • eles: string | CollectionArgument

      The elements to remove in-place or a selector representing the elements to remove . All elements in the graph matching the selector are used as the passed collection.

      This function modifies the calling collection instead of returning a new one. Use of this function should be considered for performance in some cases, but otherwise should be avoided. Consider using eles.filter() or eles.remove() instead. Use this function only on new collections that you create yourself, using cy.collection(). This ensures that you do not unintentionally modify another collection.

      Examples With a collection:

    Returns this

    var col = cy.collection(); // new, empty collection
    var e = cy.$('#e');
    col.merge( cy.nodes() );
    col.unmerge( e );

    With a selector:
    var col = cy.collection(); // new, empty collection
    col.merge( cy.nodes() );
    col.unmerge('#e');