-
Notifications
You must be signed in to change notification settings - Fork 0
Collection
A collection is an object that contains a set of elements. For the plain object used to create an element when loading a graph, see the plain element documentation.
You can access the collection API by getting a collection from the graph. You can get elements via the graph manipulation and accessor functions in the core object API.
- Graph manipulation : adding and removing elements from the graph
- Data & group : storing and reading client data for elements, and reading an elements' groups
- Dimensions & positioning : reading and manipulating dimensions and position
- Styling : reading and altering visual style
- Animation : animating visual style and position
- Selection : setting and getting whether elements are selected
- Events : handling events
- Comparison : comparing elements
- Tranversing & iteration : iterating and traversing over collections
- Statistics : statistics about nodes and edges
A collection contains a set of nodes and edges. Calling a function applies the function to all elements in the collection. When reading values from a collection, eles.data() for example, the value of the first element in the collection is returned. This follows the jQuery convention. For example:
// assume graph:
// n1[weight = 10], n2[weight = 60], n3[weight = 90]
var weight = cy.nodes().data("weight"); // returns 10You can insure that you're reading from the element you want by using a selector to narrow down the collection to one element (i.e. eles.size() == 1) or the eles.eq() function.