Program: 24949
Project: 24949
Buggy source:
public <T>ExplicitFMeasureInfo score(final Iterable<Set<T>> predicted,final Iterable<Set<T>> gold){
  double linkF1Sum=0.0;
  double linkPrecisionSum=0.0;
  double linkRecallSum=0.0;
  final Multimap<T,Set<T>> predictedItemToGroup=CollectionUtils.makeSetElementsToContainersMultimap(predicted);
  final Multimap<T,Set<T>> goldItemToGroup=CollectionUtils.makeSetElementsToContainersMultimap(gold);
  final ImmutableSet<T> keyItems=ImmutableSet.copyOf(concat(gold));
  if (keyItems.isEmpty()) {
    if (predictedItemToGroup.isEmpty()) {
      return new ExplicitFMeasureInfo(1.0,1.0,1.0);
    }
 else {
      return new ExplicitFMeasureInfo(0.0,0.0,0.0);
    }
  }
  for (  final T keyItem : keyItems) {
    final Set<T> predictedNeighbors=ImmutableSet.copyOf(without(concat(predictedItemToGroup.get(keyItem)),keyItem));
    final Set<T> goldNeighbors=ImmutableSet.copyOf(without(concat(goldItemToGroup.get(keyItem)),keyItem));
    final boolean predictedAndGoldAreSingleton=predictedNeighbors.isEmpty() && goldNeighbors.isEmpty();
    if (!predictedAndGoldAreSingleton) {
      int truePositiveLinks=Sets.intersection(predictedNeighbors,goldNeighbors).size();
      int falsePositiveLinks=Sets.difference(predictedNeighbors,goldNeighbors).size();
      int falseNegativeLinks=Sets.difference(goldNeighbors,predictedNeighbors).size();
      final FMeasureCounts fMeasureCounts=FMeasureCounts.from(truePositiveLinks,falsePositiveLinks,falseNegativeLinks);
      linkF1Sum+=fMeasureCounts.F1();
      linkPrecisionSum+=fMeasureCounts.precision();
      linkRecallSum+=fMeasureCounts.recall();
    }
 else {
      linkF1Sum+=1.0;
      linkPrecisionSum+=1.0;
      linkRecallSum+=1.0;
    }
  }
  return new ExplicitFMeasureInfo(linkPrecisionSum / keyItems.size(),linkRecallSum / keyItems.size(),linkF1Sum / keyItems.size());
}

Fixed version (ground truth):
public <T>ExplicitFMeasureInfo score(final Iterable<Set<T>> predicted,final Iterable<Set<T>> gold){
  double linkF1Sum=0.0;
  double linkPrecisionSum=0.0;
  double linkRecallSum=0.0;
  final Multimap<T,Set<T>> predictedItemToGroup=CollectionUtils.makeSetElementsToContainersMultimap(predicted);
  final Multimap<T,Set<T>> goldItemToGroup=CollectionUtils.makeSetElementsToContainersMultimap(gold);
  final ImmutableSet<T> keyItems=ImmutableSet.copyOf(concat(gold));
  final ImmutableSet<T> predictedItems=ImmutableSet.copyOf(concat(predicted));
  checkArgument(keyItems.containsAll(predictedItems),"String_Node_Str");
  if (keyItems.isEmpty()) {
    if (predictedItemToGroup.isEmpty()) {
      return new ExplicitFMeasureInfo(1.0,1.0,1.0);
    }
 else {
      return new ExplicitFMeasureInfo(0.0,0.0,0.0);
    }
  }
  for (  final T keyItem : keyItems) {
    final Set<T> predictedNeighbors=ImmutableSet.copyOf(without(concat(predictedItemToGroup.get(keyItem)),keyItem));
    final Set<T> goldNeighbors=ImmutableSet.copyOf(without(concat(goldItemToGroup.get(keyItem)),keyItem));
    final boolean predictedAndGoldAreSingleton=predictedNeighbors.isEmpty() && goldNeighbors.isEmpty();
    if (!predictedAndGoldAreSingleton) {
      int truePositiveLinks=Sets.intersection(predictedNeighbors,goldNeighbors).size();
      int falsePositiveLinks=Sets.difference(predictedNeighbors,goldNeighbors).size();
      int falseNegativeLinks=Sets.difference(goldNeighbors,predictedNeighbors).size();
      final FMeasureCounts fMeasureCounts=FMeasureCounts.from(truePositiveLinks,falsePositiveLinks,falseNegativeLinks);
      linkF1Sum+=fMeasureCounts.F1();
      linkPrecisionSum+=fMeasureCounts.precision();
      linkRecallSum+=fMeasureCounts.recall();
    }
 else {
      final boolean appearsInPredicted=predictedItems.contains(keyItem);
      if (appearsInPredicted) {
        linkF1Sum+=1.0;
        linkPrecisionSum+=1.0;
        linkRecallSum+=1.0;
      }
    }
  }
  return new ExplicitFMeasureInfo(linkPrecisionSum / predictedItems.size(),linkRecallSum / keyItems.size(),linkF1Sum / keyItems.size());
}