Logo Search packages:      
Sourcecode: cdk version File versions  Download package

static void org::openscience::cdk::graph::PathTools::breadthFirstSearch ( IAtomContainer  ac,
Vector  sphere,
IMolecule  molecule,
int  max 
) [inline, static]

Performs a breadthFirstSearch in an AtomContainer starting with a particular sphere, which usually consists of one start atom. While searching the graph, the method marks each visited atom. It then puts all the atoms connected to the atoms in the given sphere into a new vector which forms the sphere to search for the next recursive method call. All atoms that have been visited are put into a molecule container. This breadthFirstSearch does thus find the connected graph for a given start atom.

ac The AtomContainer to be searched
sphere A sphere of atoms to start the search with
molecule A molecule into which all the atoms and bonds are stored that are found during search

Definition at line 249 of file PathTools.java.

References org::openscience::cdk::interfaces::IAtomContainer::addAtom(), org::openscience::cdk::interfaces::IAtomContainer::addBond(), org::openscience::cdk::interfaces::IAtomContainer::addLonePair(), org::openscience::cdk::interfaces::IAtomContainer::addSingleElectron(), breadthFirstSearch(), org::openscience::cdk::interfaces::IAtomContainer::getAtomCount(), org::openscience::cdk::interfaces::IBond::getConnectedAtom(), org::openscience::cdk::interfaces::IAtomContainer::getConnectedBondsList(), org::openscience::cdk::interfaces::IAtomContainer::getConnectedLonePairsList(), org::openscience::cdk::interfaces::IAtomContainer::getConnectedSingleElectronsList(), org::openscience::cdk::interfaces::IChemObject::getFlag(), and org::openscience::cdk::interfaces::IChemObject::setFlag().

        IAtom atom;
        IAtom nextAtom;
        Vector newSphere = new Vector();
        for (int f = 0; f < sphere.size(); f++) {
            atom = (IAtom) sphere.elementAt(f);
            //logger.debug("atoms  "+ atom + f);
            //logger.debug("sphere size  "+ sphere.size());
            // first copy LonePair's and SingleElectron's of this Atom as they need
            // to be copied too
            java.util.List lonePairs = ac.getConnectedLonePairsList(atom);
            //logger.debug("found #ec's: " + lonePairs.length);
            for (int i = 0; i < lonePairs.size(); i++) molecule.addLonePair((ILonePair)lonePairs.get(i));
            java.util.List singleElectrons = ac.getConnectedSingleElectronsList(atom);
            for (int i = 0; i < singleElectrons.size(); i++) molecule.addSingleElectron((ISingleElectron)singleElectrons.get(i));
            // now look at bonds
            java.util.List bonds = ac.getConnectedBondsList(atom);
            for (int g = 0; g < bonds.size(); g++) {
                  IBond bond = (IBond)bonds.get(g);
                if (!bond.getFlag(CDKConstants.VISITED)) {
                    bond.setFlag(CDKConstants.VISITED, true);
                nextAtom = bond.getConnectedAtom(atom);
                if (!nextAtom.getFlag(CDKConstants.VISITED)) {
//                            logger.debug("wie oft???");
                    nextAtom.setFlag(CDKConstants.VISITED, true);
            if (max > -1 && molecule.getAtomCount() > max)
        if (newSphere.size() > 0) {
            breadthFirstSearch(ac, newSphere, molecule, max);

Generated by  Doxygen 1.6.0   Back to index