code: function Collection(cy, elements, options) {
    if (cy === undefined || !core(cy)) {
      error('A collection must have a reference to the core');
      return;
    }
  
    var map = new Map$1();
    var createdElements = false;
  
    if (!elements) {
      elements = [];
    } else if (elements.length > 0 && plainObject(elements[0]) && !element(elements[0])) {
      createdElements = true; // make elements from json and restore all at once later
  
      var eles = [];
      var elesIds = new Set$1();
  
      for (var i = 0, l = elements.length; i < l; i++) {
        var json = elements[i];
  
        if (json.data == null) {
          json.data = {};
        }
  
        var _data = json.data; // make sure newly created elements have valid ids
  
        if (_data.id == null) {
          _data.id = idFactory.generate(cy, json);
        } else if (cy.hasElementWithId(_data.id) || elesIds.has(_data.id)) {
          continue; // can't create element if prior id already exists
        }
  
        var ele = new Element(cy, json, false);
        eles.push(ele);
        elesIds.add(_data.id);
      }
  
      elements = eles;
    }
  
    this.length = 0;
  
    for (var _i = 0, _l = elements.length; _i < _l; _i++) {
      var element$$1 = elements[_i];
  
      if (element$$1 == null) {
        continue;
      }
  
      var id = element$$1._private.data.id;
  
      if (options == null || options.unique && !map.has(id)) {
        map.set(id, {
          index: this.length,
          ele: element$$1
        });
        this[this.length] = element$$1;
        this.length++;
      }
    }
  
    this._private = {
      cy: cy,
      map: map
    }; // restore the elements if we created them from json
  
    if (createdElements) {
      this.restore();
    }
  }
docs: represents a set of nodes, edges, or both together