Assigns a set of rings to groups each sharing a bond.

@param rBondsArray
@return A List of Lists each containing the ring indices of a set of fused rings
186872
private List<List<Integer>> assignRingGroups(List<Integer[]> rBondsArray) {
        List<List<Integer>> ringGroups;
        ringGroups = new ArrayList<List<Integer>>();
        for (int i = 0; i < rBondsArray.size() - 1; i++) { //for each ring except the last in rBondsArray
            for (int j = 0; j < rBondsArray.get(i).length; j++) { //for each bond in each ring

                //check there's no shared bond with any other ring already in ringGroups
                for (int k = i + 1; k < rBondsArray.size(); k++) {
                    for (int l = 0; l < rBondsArray.get(k).length; l++) { //for each ring in each ring

                        //Is there a bond in common? Then add both rings
                        if (Objects.equals(rBondsArray.get(i)[j], rBondsArray.get(k)[l])) {
                            if (i != k) {
                                ringGroups.add(new ArrayList<Integer>());
                                ringGroups.get(ringGroups.size() - 1).add(i);
                                ringGroups.get(ringGroups.size() - 1).add(k);
                            }
                        }
                    }
                }
            }
        }
        while (combineGroups(ringGroups));

        //Anything not added yet is a singleton
        for (int i = 0; i < rBondsArray.size(); i++) {
            boolean found = false;
            for (int j = 0; j < ringGroups.size(); j++) {
                if (ringGroups.get(j).contains(i)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                ringGroups.add(new ArrayList<Integer>());
                ringGroups.get(ringGroups.size() - 1).add(i);
            }
        }
        return ringGroups;
    }
616904
public List<int[]> allNodes(final int r) {
    final List<int[]> result = new ArrayList<>();
    if (r < 2)
      return result;
    mark(r);
    for (int n = 0; n < this.nodesize; n++) {
      if ((level(n) & MARKON) != 0) {
        final BddNode node = this.nodes[n];
        node.level &= MARKOFF;
        result.add(new int[]{n, this.level2var[node.level], node.low, node.high});
      }
    }
    return result;
  }
999
private IRingSet recoverRingSystem(IAtomContainer mol) {
        IRingSet ringSet = mol.getBuilder().newInstance(IRingSet.class);
        for (Integer[] bondNumbers : listOfRings) {
            IRing ring = mol.getBuilder().newInstance(IRing.class, bondNumbers.length);
            for (int bondNumber : bondNumbers) {
                IBond bond = mol.getBond(bondNumber);
                ring.addBond(bond);
                if (!ring.contains(bond.getBegin())) ring.addAtom(bond.getBegin());
                if (!ring.contains(bond.getEnd())) ring.addAtom(bond.getEnd());
            }
            ringSet.addAtomContainer(ring);
        }
        return ringSet;
    }
675992
public static int[][] getMatrix(IAtomContainer container) {
        IBond bond;
        int indexAtom1;
        int indexAtom2;
        int[][] conMat = new int[container.getAtomCount()][container.getAtomCount()];
        for (int f = 0; f < container.getBondCount(); f++) {
            bond = container.getBond(f);
            indexAtom1 = container.indexOf(bond.getBegin());
            indexAtom2 = container.indexOf(bond.getEnd());
            conMat[indexAtom1][indexAtom2] = 1;
            conMat[indexAtom2][indexAtom1] = 1;
        }
        return conMat;
    }
10460
public IRingSet findEssentialRings() {
        if (atomContainer == null) {
            return null;
        }
        IRingSet ringSet = toRingSet(atomContainer, cycleBasis().essentialCycles());
        //		atomContainer.setProperty(CDKConstants.ESSENTIAL_RINGS, ringSet);
        return ringSet;
    }
441943
List<AtomPair> findCongestedPairs() {

        List<AtomPair> pairs = new ArrayList<>();

        // only add a single pair between each ring system, otherwise we
        // may have many pairs that are actually all part of the same
        // congestion
        Set<IntTuple> ringpairs = new HashSet<>();

        // score at which to check for crossing bonds
        final double maybeCrossed = 1.0 / (2 * 2);

        final int numAtoms = mol.getAtomCount();
        for (int u = 0; u < numAtoms; u++) {
            for (int v = u + 1; v < numAtoms; v++) {
                double contribution = congestion.contribution(u, v);
                // <0 = bonded
                if (contribution <= 0)
                    continue;

                // we don't modify ring bonds with the class to when the atoms
                // same ring systems we can't reduce the congestion
                if (ringsystems[u] > 0 && ringsystems[u] == ringsystems[v])
                    continue;

                // an un-bonded atom pair is congested if they're and with a certain distance
                // or any of their bonds are crossing
                if (contribution >= MIN_SCORE || contribution >= maybeCrossed && haveCrossingBonds(u, v)) {

                    int uWeight = mol.getAtom(u).getProperty(AtomPlacer.PRIORITY);
                    int vWeight = mol.getAtom(v).getProperty(AtomPlacer.PRIORITY);

                    int[] path = uWeight > vWeight ? apsp.from(u).pathTo(v)
                                                   : apsp.from(v).pathTo(u);

                    // something not right here if the len is < 3
                    int len = path.length;
                    if (len < 3) continue;

                    // build the seqAt and bndAt lists from shortest path
                    int[] seqAt = new int[len - 2];
                    IBond[] bndAt = new IBond[len - 1];
                    makeAtmBndQueues(path, seqAt, bndAt);

                    // we already know about this collision between these ring systems
                    // so dont add the pair
                    if (ringsystems[u] > 0 && ringsystems[v] > 0 &&
                            !ringpairs.add(new IntTuple(ringsystems[u], ringsystems[v])))
                        continue;

                    // add to pairs to overlap
                    pairs.add(new AtomPair(u, v, seqAt, bndAt));
                }
            }
        }

        // sort the pairs to attempt consistent overlap resolution (order independent)
        Collections.sort(pairs, new Comparator<AtomPair>() {
            @Override
            public int compare(AtomPair a, AtomPair b) {
                int a1 = atoms[a.fst].getProperty(AtomPlacer.PRIORITY);
                int a2 = atoms[a.snd].getProperty(AtomPlacer.PRIORITY);
                int b1 = atoms[b.fst].getProperty(AtomPlacer.PRIORITY);
                int b2 = atoms[b.snd].getProperty(AtomPlacer.PRIORITY);
                int amin, amax;
                int bmin, bmax;
                if (a1 < a2) {
                    amin = a1;
                    amax = a2;
                }
                else {
                    amin = a2;
                    amax = a1;
                }
                if (b1 < b2) {
                    bmin = a1;
                    bmax = a2;
                }
                else {
                    bmin = a2;
                    bmax = a1;
                }
                int cmp = Integer.compare(amin, bmin);
                if (cmp != 0) return cmp;
                return Integer.compare(amax, bmax);
            }
        });

        return pairs;
    }
167836
def scaffold_coords(rings):
    
    rs = deque(sorted(rings, key=len, reverse=True))
    base = rs.popleft()
    first = base[0]
    coords = {first: [0, 0, 0, 1]}
    attach_spiro(coords, base, first)
    # display(coords)
    while rs:
        r = rs.popleft()
        isec = list(set(coords) & set(r))
        if not isec:
            rs.append(r)
        elif len(isec) == 1:  # spiro
            attach_spiro(coords, r, isec)
        elif len(isec) == 2:  # fuse
            attach_fused(coords, r, isec)
        else:  # bridge or append
            bridge(coords, r, isec)
        # display(coords)
    return coords
959598
public IRingSet getAllRings() throws NoSuchAtomException {
        IRingSet ringset = getBasicRings();
        IRing newring;

        int nBasicRings = ringset.getAtomContainerCount();
        for (int i = 0; i < nBasicRings; i++)
            getBondsInRing(molecule, (IRing) ringset.getAtomContainer(i), cb[i]);

        for (int i = 0; i < nBasicRings; i++) {
            for (int j = i + 1; j < nBasicRings; j++) {
                //logger.debug("combining rings "+(i+1)+","+(j+1));
                newring = combineRings(ringset, i, j);
                //newring = combineRings((Ring)ringset.get(i),(Ring)ringset.get(j));
                if (newring != null) ringset.addAtomContainer(newring);
            }
        }

        return ringset;
    }
920978
private static IBond[] neighbors(int v, int[][] g, EdgeToBondMap bondMap) {
        int[]   ws    = g[v];
        IBond[] bonds = new IBond[ws.length];
        for (int i = 0; i < ws.length; i++) {
            bonds[i] = bondMap.get(v, ws[i]);
        }
        return bonds;
    }
1105619
def _jit_give_bond_array(pos, bond_radii, self_bonding_allowed=False):
        
        n = pos.shape[0]
        bond_array = np.empty((n, n), dtype=nb.boolean)

        for i in range(n):
            for j in range(i, n):
                D = 0
                for h in range(3):
                    D += (pos[i, h] - pos[j, h])**2
                B = (bond_radii[i] + bond_radii[j])**2
                bond_array[i, j] = (B - D) >= 0
                bond_array[j, i] = bond_array[i, j]
        if not self_bonding_allowed:
            for i in range(n):
                bond_array[i, i] = False
        return bond_array
382096
public static final Atom[] getAllAtomArray(Chain c) {
		List<Atom> atoms = new ArrayList<Atom>();

		for (Group g : c.getAtomGroups()) {
			if (g.isWater())
				continue;
			for (Atom a : g.getAtoms()) {
				atoms.add(a);
			}
		}
		return atoms.toArray(new Atom[atoms.size()]);
	}
1017830
public static void sort(IRingSet ringSet) {
        List<IRing> ringList = new ArrayList<IRing>();
        for (IAtomContainer atomContainer : ringSet.atomContainers()) {
            ringList.add((IRing) atomContainer);
        }
        Collections.sort(ringList, new RingSizeComparator(RingSizeComparator.SMALL_FIRST));
        ringSet.removeAllAtomContainers();
        for (IAtomContainer aRingList : ringList)
            ringSet.addAtomContainer(aRingList);

    }
802872
@Override
    public List<IBond> getConnectedBondsList(IAtom atom) {
        List<IBond> bondsList = new ArrayList<IBond>();
        for (int i = 0; i < bondCount; i++) {
            if (bonds[i].contains(atom)) bondsList.add(bonds[i]);
        }
        return bondsList;
    }
332864
public IRingSet getLargestRingSet(List<IRingSet> ringSystems) {
        IRingSet       largestRingSet = null;
        int            atomNumber     = 0;
        IAtomContainer container      = null;
        for (int i = 0; i < ringSystems.size(); i++) {
            container = getAllInOneContainer(ringSystems.get(i));
            if (atomNumber < container.getAtomCount()) {
                atomNumber = container.getAtomCount();
                largestRingSet = ringSystems.get(i);
            }
        }
        return largestRingSet;
    }
31140
private void identifyBonds() {
        IAtomContainer spt = getSpanningTree();
        IRing ring;
        int nBasicRings = 0;
        for (int i = 0; i < totalEdgeCount; i++) {
            if (!bondsInTree[i]) {
                ring = getRing(spt, molecule.getBond(i));
                for (int b = 0; b < ring.getBondCount(); b++) {
                    int m = molecule.indexOf(ring.getBond(b));
                    cb[nBasicRings][m] = 1;
                }
                nBasicRings++;
            }
        }
        bondsAcyclicCount = 0;
        bondsCyclicCount = 0;
        for (int i = 0; i < totalEdgeCount; i++) {
            int s = 0;
            for (int j = 0; j < nBasicRings; j++) {
                s += cb[j][i];
            }
            switch (s) {
                case (0): {
                    bondsAcyclicCount++;
                    break;
                }
                case (1): {
                    bondsCyclicCount++;
                    break;
                }
                default: {
                    bondsCyclicCount++;
                }
            }
        }
        identifiedBonds = true;
    }
576567
public static IAtomContainer make4x3CondensedRings() {
        IAtomContainer mol = new AtomContainer();
        mol.addAtom(new Atom("C")); // 1
        mol.addAtom(new Atom("C")); // 2
        mol.addAtom(new Atom("C")); // 3
        mol.addAtom(new Atom("C")); // 4
        mol.addAtom(new Atom("C")); // 5
        mol.addAtom(new Atom("C")); // 6

        mol.addBond(0, 1, IBond.Order.SINGLE); // 1
        mol.addBond(1, 2, IBond.Order.SINGLE); // 2
        mol.addBond(2, 0, IBond.Order.SINGLE); // 3
        mol.addBond(2, 3, IBond.Order.SINGLE); // 4
        mol.addBond(1, 3, IBond.Order.SINGLE); // 5
        mol.addBond(3, 4, IBond.Order.SINGLE); // 6
        mol.addBond(4, 2, IBond.Order.SINGLE); // 7
        mol.addBond(4, 5, IBond.Order.SINGLE); // 8
        mol.addBond(5, 3, IBond.Order.SINGLE); // 9

        return mol;
    }
1358257
@Override
    public Collection<List<IAtom>> findRings(IAtomContainer molecule) {
        if (molecule == null) return null;
        rings.clear();
        PathGraph graph = new PathGraph(molecule);

        for (int i = 0; i < molecule.getAtomCount(); i++) {
            List<PathEdge> edges = graph.remove(molecule.getAtom(i));

            for (PathEdge edge : edges) {
                List<IAtom> ring = edge.getAtoms();
                rings.add(ring);
            }
        }

        return rings;
    }