private void breadthFirstSearch ( IAtomContainer container , List < IAtom > sphere , List < IAtom > path ) throws CDKException { IAtom nextAtom ; List < IAtom > newSphere = new ArrayList < IAtom > ( ) ; //logger.debug("Start of breadthFirstSearch"); for ( IAtom atom : sphere ) { //logger.debug("BreadthFirstSearch around atom " + (atomNr + 1)); List bonds = container . getConnectedBondsList ( atom ) ; for ( Object bond : bonds ) { nextAtom = ( ( IBond ) bond ) . getOther ( atom ) ; if ( ( container . getMaximumBondOrder ( nextAtom ) != IBond . Order . SINGLE || Math . abs ( nextAtom . getFormalCharge ( ) ) >= 1 || nextAtom . getFlag ( CDKConstants . ISAROMATIC ) || nextAtom . getSymbol ( ) . equals ( "N" ) || nextAtom . getSymbol ( ) . equals ( "O" ) ) & ! nextAtom . getFlag ( CDKConstants . VISITED ) ) { //logger.debug("BDS> AtomNr:"+container.indexOf(nextAtom)+" maxBondOrder:"+container.getMaximumBondOrder(nextAtom)+" Aromatic:"+nextAtom.getFlag(CDKConstants.ISAROMATIC)+" FormalCharge:"+nextAtom.getFormalCharge()+" Charge:"+nextAtom.getCharge()+" Flag:"+nextAtom.getFlag(CDKConstants.VISITED)); path . add ( nextAtom ) ; //logger.debug("BreadthFirstSearch is meeting new atom " + (nextAtomNr + 1)); nextAtom . setFlag ( CDKConstants . VISITED , true ) ; if ( container . getConnectedBondsCount ( nextAtom ) > 1 ) { newSphere . add ( nextAtom ) ; } } else { nextAtom . setFlag ( CDKConstants . VISITED , true ) ; } } } if ( newSphere . size ( ) > 0 ) { breadthFirstSearch ( container , newSphere , path ) ; } }
Performs a breadthFirstSearch in an AtomContainer starting with a particular sphere which usually consists of one start atom and searches for a pi system .