Program: 95872
Project: 95872
Buggy source:
private int getHighestWeight(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages){
  int desiredPartition=0;
  Map<Integer,Integer> countNeighbours=new HashMap<>();
  Map<Integer,Float> partitionWeight=new HashMap<>();
  for (  IntWritable message : messages) {
    if (!countNeighbours.containsKey(message.get())) {
      countNeighbours.put(message.get(),1);
    }
 else {
      countNeighbours.put(message.get(),countNeighbours.get(message.get()) + 1);
    }
  }
  int partitionCount=Integer.valueOf(getConf().get(NUMBER_OF_PARTITIONS));
  int totalNeighbours=countNeighbours.size();
  for (int i=0; i < partitionCount; i++) {
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + i;
    int load=getAggregatedValue(aggregator);
    int numNeighboursInI=countNeighbours.get(i);
    float weight=(1 / load) * numNeighboursInI / totalNeighbours;
    partitionWeight.put(i,weight);
  }
  float highestWeight=0;
  float secondHighestWeight=0;
  int secondKey=0;
  for (  Map.Entry<Integer,Float> entry : partitionWeight.entrySet()) {
    if (highestWeight < entry.getValue()) {
      secondHighestWeight=highestWeight;
      secondKey=desiredPartition;
      desiredPartition=entry.getKey();
      highestWeight=entry.getValue();
    }
  }
  if (secondHighestWeight == highestWeight) {
    if (vertex.getValue().getCurrentVertexValue().get() == desiredPartition || vertex.getValue().getCurrentVertexValue().get() == secondKey) {
      desiredPartition=vertex.getValue().getCurrentVertexValue().get();
    }
  }
  return desiredPartition;
}

Fixed version (ground truth):
private int getHighestWeight(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages){
  int desiredPartition=0;
  Map<Integer,Integer> countNeighbours=new HashMap<>();
  Map<Integer,Double> partitionWeight=new HashMap<>();
  for (  IntWritable message : messages) {
    if (!countNeighbours.containsKey(message.get())) {
      countNeighbours.put(message.get(),1);
    }
 else {
      countNeighbours.put(message.get(),countNeighbours.get(message.get()) + 1);
    }
  }
  int partitionCount=Integer.valueOf(getConf().get(NUMBER_OF_PARTITIONS));
  int totalNeighbours=countNeighbours.size();
  for (int i=0; i < partitionCount; i++) {
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + i;
    int load=getAggregatedValue(aggregator);
    int numNeighboursInI=countNeighbours.get(i);
    double weight=(1 / load) * numNeighboursInI / totalNeighbours;
    partitionWeight.put(i,weight);
  }
  double highestWeight=0;
  double secondHighestWeight=0;
  int secondKey=0;
  for (  Map.Entry<Integer,Double> entry : partitionWeight.entrySet()) {
    if (highestWeight < entry.getValue()) {
      secondHighestWeight=highestWeight;
      secondKey=desiredPartition;
      desiredPartition=entry.getKey();
      highestWeight=entry.getValue();
    }
  }
  if (secondHighestWeight == highestWeight) {
    if (vertex.getValue().getCurrentVertexValue().get() == desiredPartition || vertex.getValue().getCurrentVertexValue().get() == secondKey) {
      desiredPartition=vertex.getValue().getCurrentVertexValue().get();
    }
  }
  return desiredPartition;
}