public static boolean isIsomorph ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { if ( sourceGraph instanceof IQueryAtomContainer ) { throw new CDKException ( "The first IAtomContainer must not be an IQueryAtomContainer" ) ; } if ( targetGraph . getAtomCount ( ) != sourceGraph . getAtomCount ( ) ) { return false ; } // check single atom case if ( targetGraph . getAtomCount ( ) == 1 ) { IAtom atom = sourceGraph . getAtom ( 0 ) ; IAtom atom2 = targetGraph . getAtom ( 0 ) ; if ( atom instanceof IQueryAtom ) { IQueryAtom qAtom = ( IQueryAtom ) atom ; return qAtom . matches ( targetGraph . getAtom ( 0 ) ) ; } else if ( atom2 instanceof IQueryAtom ) { IQueryAtom qAtom = ( IQueryAtom ) atom2 ; return qAtom . matches ( sourceGraph . getAtom ( 0 ) ) ; } else { String atomSymbol = atom2 . getSymbol ( ) ; return sourceGraph . getAtom ( 0 ) . getSymbol ( ) . equals ( atomSymbol ) ; } } return ( getIsomorphMap ( sourceGraph , targetGraph , shouldMatchBonds ) != null ) ; }
Tests if sourceGraph and targetGraph are isomorph .