public static boolean isMonogamous(Collection<Family> families){
  final HashSet<String> parents=new HashSet<>();
  for (  Family f : families) {
    if (!parents.add(f.getFather())) {
      return false;
    }
    if (!parents.add(f.getMother())) {
      return false;
    }
  }
  return true;
}

public static boolean isMonogamous ( Collection < Family > families ) { final HashSet < String > parents = new HashSet < > ( ) ; for ( Family f : families ) { if ( ! parents . add ( f . getFather ( ) ) ) { return false ; } if ( ! parents . add ( f . getMother ( ) ) ) { return false ; } } return true ; }
detects the presence of genetic non - monogamy within an set of families
