public static int getNumBondsInGroup ( List < Atom > atomsInGroup ) { int bondCounter = 0 ; for ( Atom atom : atomsInGroup ) { if ( atom . getBonds ( ) == null ) { continue ; } for ( Bond bond : atom . getBonds ( ) ) { // Now set the bonding information. Atom other = bond . getOther ( atom ) ; // If both atoms are in the group if ( atomsInGroup . indexOf ( other ) != - 1 ) { Integer firstBondIndex = atomsInGroup . indexOf ( atom ) ; Integer secondBondIndex = atomsInGroup . indexOf ( other ) ; // Don't add the same bond twice if ( firstBondIndex < secondBondIndex ) { bondCounter ++ ; } } } } return bondCounter ; }
Find the number of bonds in a group