Determine whether the bond is cyclic. Note this currently requires a
linear search to look-up the indices of each atoms.

@param bond a bond of the container
@return whether the vertex at the given index is in a cycle
183765
public boolean cyclic(IBond bond) {
        // XXX: linear search - but okay for now
        int u = container.indexOf(bond.getBegin());
        int v = container.indexOf(bond.getEnd());
        if (u < 0 || v < 0) throw new NoSuchElementException("atoms of the bond are not found in the container");
        return searcher.cyclic(u, v);
    }
630596
private IBond findBond(IAtom beg1, IAtom beg2, IAtom end) {
        IBond bond = container.getBond(beg1, end);
        if (bond != null)
            return bond;
        return container.getBond(beg2, end);
    }
37670
private boolean isSP2Bond(IBond bond) {
        return bond.getAtomCount() == 2 && bond.getBegin().getHybridization() == Hybridization.SP2
               && bond.getEnd().getHybridization() == Hybridization.SP2;
    }
851880
@Override
    public boolean compare(Object object) {
        if (object instanceof IBond) {
            Bond bond = (Bond) object;
            for (IAtom atom : atoms) {
                if (!bond.contains(atom)) {
                    return false;
                }
            }

            // not important ??!!
            //if (order==bond.order)
            //  return false;

            return true;
        }
        return false;
    }
403951
public static double predictIP(IAtomContainer container, IBond bond) throws CDKException {
        double value = 0;

        if (bond.getOrder().equals(IBond.Order.SINGLE)) return value;

        //if some of the atoms belongs to some of the heteroatom family than
        // it can not ionized
        for (int i = 0; i < 2; i++) {
            IAtom atom = bond.getAtom(i);
            if (familyHalogen(atom))
                return value;
            else if (familyOxygen(atom))
                return value;
            else if (familyNitrogen(atom)) return value;
        }

        if (!familyBond(container, bond)) return value;

        return getDTBondF(getQSARs(container, bond));
    }
1321836
private void checkBond(IAtomContainer atomContainer, int index) throws CDKException {
        IBond bond = atomContainer.getBond(index);

        if (bond != null && bond.getFlag(CDKConstants.SINGLE_OR_DOUBLE)) {
            try {
                oldBondOrder = bond.getOrder();
                bond.setOrder(IBond.Order.SINGLE);
                setMaxBondOrder(bond, atomContainer);
            } catch (CDKException e) {
                bond.setOrder(oldBondOrder);
                logger.debug(e);
            }
        }
    }
665458
public static int convertBondOrder(IBond bond) {
        int value = 0;
        switch (bond.getOrder()) {
            case QUADRUPLE:
                value = 4;
                break;
            case TRIPLE:
                value = 3;
                break;
            case DOUBLE:
                value = 2;
                break;
            case SINGLE:
                value = 1;
                break;
            default:
                value = 0;
        }
        return value;
    }
1199573
private void decideBondOrder(IAtomContainer atomContainer, int start) throws CDKException {
        for (int i = 0; i < atomContainer.getBondCount(); i++)
            if (atomContainer.getBond(i).getFlag(CDKConstants.SINGLE_OR_DOUBLE))
                atomContainer.getBond(i).setOrder(IBond.Order.SINGLE);

        for (int i = start; i < atomContainer.getBondCount(); i++) {
            checkBond(atomContainer, i);
        }
        /*
         * If we don't start with first bond, then we have to check the bonds
         * before the bond we started with.
         */
        if (start > 0) {
            for (int i = start - 1; i >= 0; i--) {
                checkBond(atomContainer, i);
            }
        }
    }
162430
private boolean isStereoBond(IBond bond) {
        return bond.getStereo() != IBond.Stereo.NONE && bond.getStereo() != (IBond.Stereo) CDKConstants.UNSET
                && bond.getStereo() != IBond.Stereo.E_Z_BY_COORDINATES;
    }
292065
public static int convertBondStereo(IBond bond) {
        int value = 0;
        switch (bond.getStereo()) {
            case UP:
                value = 1;
                break;
            case UP_INVERTED:
                value = 1;
                break;
            case DOWN:
                value = 6;
                break;
            case DOWN_INVERTED:
                value = 6;
                break;
            case UP_OR_DOWN:
                value = 4;
                break;
            case UP_OR_DOWN_INVERTED:
                value = 4;
                break;
            case E_OR_Z:
                value = 3;
                break;
            default:
                value = 0;
        }
        return value;
    }
394538
private static int countAlignedBonds(IAtomContainer mol) {
        final double ref = Math.toRadians(30);
        final double diff = Math.toRadians(1);
        int count = 0;
        for (IBond bond : mol.bonds()) {
            Point2d beg = bond.getBegin().getPoint2d();
            Point2d end = bond.getEnd().getPoint2d();
            if (beg.x > end.x) {
                Point2d tmp = beg;
                beg = end;
                end = tmp;
            }
            Vector2d vec = new Vector2d(end.x - beg.x, end.y - beg.y);
            double angle = Math.atan2(vec.y, vec.x);

            if (Math.abs(angle) - ref < diff) {
                count++;
            }
        }
        return count;
    }
866619
public boolean areIntersected(IBond bond1, IBond bond2) {
        double x1 = 0, x2 = 0, x3 = 0, x4 = 0;
        double y1 = 0, y2 = 0, y3 = 0, y4 = 0;
        //Point2D.Double p1 = null, p2 = null, p3 = null, p4 = null;

        x1 = bond1.getBegin().getPoint2d().x;
        x2 = bond1.getEnd().getPoint2d().x;
        x3 = bond2.getBegin().getPoint2d().x;
        x4 = bond2.getEnd().getPoint2d().x;

        y1 = bond1.getBegin().getPoint2d().y;
        y2 = bond1.getEnd().getPoint2d().y;
        y3 = bond2.getBegin().getPoint2d().y;
        y4 = bond2.getEnd().getPoint2d().y;

        Line2D.Double line1 = new Line2D.Double(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2));
        Line2D.Double line2 = new Line2D.Double(new Point2D.Double(x3, y3), new Point2D.Double(x4, y4));

        if (line1.intersectsLine(line2)) {
            logger.debug("Two intersecting bonds detected.");
            return true;
        }
        return false;
    }
694696
private boolean isMacroCycle(IRing ring, IRingSet rs) {
        if (ring.getAtomCount() < 8)
            return false;
        for (IBond bond : ring.bonds()) {
            boolean found = false;
            for (IAtomContainer other : rs.atomContainers()) {
                if (ring == other)
                    continue;
                if (other.contains(bond)) {
                    found = true;
                    break;
                }
            }
            if (!found)
                return true;
        }
        return false;
    }
860696
@Override
    public int getConnectedAtomsCount(IAtom atom) {
        int count = 0;
        for (int i = 0; i < bondCount; i++) {
            if (bonds[i].contains(atom)) ++count;
        }
        return count;
    }
987272
private void reflect(int v, IBond bond) {
        visited[v] = true;
        IAtom atom = container.getAtom(v);
        atom.setPoint2d(reflect(atom.getPoint2d(), bond));
        for (int w : graph[v]) {
            if (!visited[w]) reflect(w, bond);
        }
    }
500277
private int getNearestBondtoAGivenAtom(IAtomContainer mol, IAtom atom, IBond bond) {
        int nearestBond = 0;
        double[] values;
        double distance = 0;
        IAtom atom0 = bond.getBegin();
        List<IBond> bondsAtLeft = mol.getConnectedBondsList(atom0);
        int partial;
        for (int i = 0; i < bondsAtLeft.size(); i++) {
            IBond curBond = bondsAtLeft.get(i);
            values = calculateDistanceBetweenAtomAndBond(atom, curBond);
            partial = mol.indexOf(curBond);
            if (i == 0) {
                nearestBond = mol.indexOf(curBond);
                distance = values[0];
            } else {
                if (values[0] < distance) {
                    nearestBond = partial;
                }
            }
        }
        return nearestBond;

    }
43900
@Override
    public boolean isSaturated(IAtom atom, IAtomContainer ac) throws CDKException {
        IAtomType[] atomTypes = getAtomTypeFactory(atom.getBuilder()).getAtomTypes(atom.getSymbol());
        if (atomTypes.length == 0) return true;
        double bondOrderSum = ac.getBondOrderSum(atom);
        IBond.Order maxBondOrder = ac.getMaximumBondOrder(atom);
        Integer hcount = atom.getImplicitHydrogenCount() == CDKConstants.UNSET ? 0 : atom.getImplicitHydrogenCount();
        Integer charge = atom.getFormalCharge() == CDKConstants.UNSET ? 0 : atom.getFormalCharge();
        try {
            logger.debug("*** Checking saturation of atom ", atom.getSymbol(), "" + ac.indexOf(atom) + " ***");
            logger.debug("bondOrderSum: " + bondOrderSum);
            logger.debug("maxBondOrder: " + maxBondOrder);
            logger.debug("hcount: " + hcount);
        } catch (Exception exc) {
            logger.debug(exc);
        }
        for (int f = 0; f < atomTypes.length; f++) {
            if (bondOrderSum - charge + hcount == atomTypes[f].getBondOrderSum()
                    && !BondManipulator.isHigherOrder(maxBondOrder, atomTypes[f].getMaxBondOrder())) {
                logger.debug("*** Good ! ***");
                return true;
            }
        }
        logger.debug("*** Bad ! ***");
        return false;
    }