initRings() {
    let openBonds = new Map(); // Close the open ring bonds (spanning tree -> graph)

    for (var i = this.graph.vertices.length - 1; i >= 0; i--) {
      let vertex = this.graph.vertices[i];

      if (vertex.value.ringbonds.length === 0) {
        continue;
      }

      for (var j = 0; j < vertex.value.ringbonds.length; j++) {
        let ringbondId = vertex.value.ringbonds[j].id;
        let ringbondBond = vertex.value.ringbonds[j].bond; // If the other ringbond id has not been discovered,
        // add it to the open bonds map and continue.
        // if the other ringbond id has already been discovered,
        // create a bond between the two atoms.

        if (!openBonds.has(ringbondId)) {
          openBonds.set(ringbondId, [vertex.id, ringbondBond]);
        } else {
          let sourceVertexId = vertex.id;
          let targetVertexId = openBonds.get(ringbondId)[0];
          let targetRingbondBond = openBonds.get(ringbondId)[1];
          let edge = new Edge(sourceVertexId, targetVertexId, 1);
          edge.setBondType(targetRingbondBond || ringbondBond || '-');
          let edgeId = this.graph.addEdge(edge);
          let targetVertex = this.graph.vertices[targetVertexId];
          vertex.addRingbondChild(targetVertexId, j);
          vertex.value.addNeighbouringElement(targetVertex.value.element);
          targetVertex.addRingbondChild(sourceVertexId, j);
          targetVertex.value.addNeighbouringElement(vertex.value.element);
          vertex.edges.push(edgeId);
          targetVertex.edges.push(edgeId);
          openBonds.delete(ringbondId);
        }
      }
    } // Get the rings in the graph (the SSSR)


    let rings = SSSR.getRings(this.graph, this.opts.experimentalSSSR);

    if (rings === null) {
      return;
    }

    for (var i = 0; i < rings.length; i++) {
      let ringVertices = [...rings[i]];
      let ringId = this.addRing(new Ring(ringVertices)); // Add the ring to the atoms

      for (var j = 0; j < ringVertices.length; j++) {
        this.graph.vertices[ringVertices[j]].value.rings.push(ringId);
      }
    } // Find connection between rings
    // Check for common vertices and create ring connections. This is a bit
    // ugly, but the ringcount is always fairly low (< 100)


    for (var i = 0; i < this.rings.length - 1; i++) {
      for (var j = i + 1; j < this.rings.length; j++) {
        let a = this.rings[i];
        let b = this.rings[j];
        let ringConnection = new RingConnection(a, b); // If there are no vertices in the ring connection, then there
        // is no ring connection

        if (ringConnection.vertices.size > 0) {
          this.addRingConnection(ringConnection);
        }
      }
    } // Add neighbours to the rings


    for (var i = 0; i < this.rings.length; i++) {
      let ring = this.rings[i];
      ring.neighbours = RingConnection.getNeighbours(this.ringConnections, ring.id);
    } // Anchor the ring to one of it's members, so that the ring center will always
    // be tied to a single vertex when doing repositionings


    for (var i = 0; i < this.rings.length; i++) {
      let ring = this.rings[i];
      this.graph.vertices[ring.members[0]].value.addAnchoredRing(ring.id);
    } // Backup the ring information to restore after placing the bridged ring.
    // This is needed in order to identify aromatic rings and stuff like this in
    // rings that are member of the superring.


    this.backupRingInformation(); // Replace rings contained by a larger bridged ring with a bridged ring

    while (this.rings.length > 0) {
      let id = -1;

      for (var i = 0; i < this.rings.length; i++) {
        let ring = this.rings[i];

        if (this.isPartOfBridgedRing(ring.id) && !ring.isBridged) {
          id = ring.id;
        }
      }

      if (id === -1) {
        break;
      }

      let ring = this.getRing(id);
      let involvedRings = this.getBridgedRingRings(ring.id);
      this.bridgedRing = true;
      this.createBridgedRing(involvedRings, ring.members[0]);
      this.bridgedRing = false; // Remove the rings

      for (var i = 0; i < involvedRings.length; i++) {
        this.removeRing(involvedRings[i]);
      }
    }
  }
Initializes rings and ringbonds for the current molecule.