nus-yam/ex-repair huggingface dataset:
Program: 95855
Project: 95855
Buggy source:
@Override public DataSet<Boolean> execute(GraphCollection<G,V,E> firstCollection,GraphCollection<G,V,E> secondCollection){
  DataSet<Tuple2<String,Long>> firstGraphLabels=labelGraphs(firstCollection);
  DataSet<Tuple2<String,Long>> secondGraphLabels=labelGraphs(secondCollection);
  DataSet<Long> firstLabelCount=Count.count(firstGraphLabels);
  DataSet<Long> matchingLabelCount=Count.count(firstGraphLabels.join(secondGraphLabels).where(0,1).equalTo(0,1));
  return Or.union(And.cross(firstCollection.isEmpty(),secondCollection.isEmpty()),Equals.cross(firstLabelCount,matchingLabelCount));
}

Fixed version (ground truth):
@Override public DataSet<Boolean> execute(GraphCollection<G,V,E> firstCollection,GraphCollection<G,V,E> secondCollection){
  DataSet<Tuple2<String,Long>> firstGraphLabels=labelGraphs(firstCollection);
  DataSet<Tuple2<String,Long>> secondGraphLabels=labelGraphs(secondCollection);
  DataSet<Long> firstLabelCount=Count.count(firstGraphLabels);
  DataSet<Long> matchingLabelCount=Count.count(firstGraphLabels.join(secondGraphLabels).where(0,1).equalTo(0,1));
  DataSet<Boolean> firstCollectionIsEmpty=firstCollection.isEmpty();
  return Or.union(And.cross(firstCollectionIsEmpty,secondCollection.isEmpty()),And.cross(Not.map(firstCollectionIsEmpty),Equals.cross(firstLabelCount,matchingLabelCount)));
}
Program: 95856
Project: 95856
Buggy source:
@Override public DataSet<Boolean> execute(GraphCollection<G,V,E> firstCollection,GraphCollection<G,V,E> secondCollection){
  DataSet<Tuple3<GradoopIdSet,GradoopIdSet,Long>> firstGraphsWithCount=getGraphElementIdsWithCount(firstCollection);
  DataSet<Tuple3<GradoopIdSet,GradoopIdSet,Long>> secondGraphsWithCount=getGraphElementIdsWithCount(secondCollection);
  DataSet<Long> distinctFirstGraphCount=Count.count(firstGraphsWithCount);
  DataSet<Long> matchingIdCount=Count.count(firstGraphsWithCount.join(secondGraphsWithCount).where(0,1,2).equalTo(0,1,2));
  return Or.union(And.cross(firstCollection.isEmpty(),secondCollection.isEmpty()),Equals.cross(distinctFirstGraphCount,matchingIdCount));
}

Fixed version (ground truth):
@Override public DataSet<Boolean> execute(GraphCollection<G,V,E> firstCollection,GraphCollection<G,V,E> secondCollection){
  DataSet<Tuple3<GradoopIdSet,GradoopIdSet,Long>> firstGraphsWithCount=getGraphElementIdsWithCount(firstCollection);
  DataSet<Tuple3<GradoopIdSet,GradoopIdSet,Long>> secondGraphsWithCount=getGraphElementIdsWithCount(secondCollection);
  DataSet<Long> distinctFirstGraphCount=Count.count(firstGraphsWithCount);
  DataSet<Long> matchingIdCount=Count.count(firstGraphsWithCount.join(secondGraphsWithCount).where(0,1,2).equalTo(0,1,2));
  DataSet<Boolean> firstCollectionIsEmpty=firstCollection.isEmpty();
  return Or.union(And.cross(firstCollectionIsEmpty,secondCollection.isEmpty()),And.cross(Not.map(firstCollectionIsEmpty),Equals.cross(distinctFirstGraphCount,matchingIdCount)));
}
Program: 95857
Project: 95857
Buggy source:
@Override public DataSet<Boolean> execute(GraphCollection<G,V,E> firstCollection,GraphCollection<G,V,E> secondCollection){
  DataSet<Tuple2<GradoopId,Long>> firstGraphIdsWithCount=getIdsWithCount(firstCollection);
  DataSet<Tuple2<GradoopId,Long>> secondGraphIdsWithCount=getIdsWithCount(secondCollection);
  DataSet<Long> distinctFirstIdCount=Count.count(firstGraphIdsWithCount);
  DataSet<Long> matchingIdCount=Count.count(firstGraphIdsWithCount.join(secondGraphIdsWithCount).where(0,1).equalTo(0,1));
  return Or.union(And.cross(firstCollection.isEmpty(),secondCollection.isEmpty()),Equals.cross(distinctFirstIdCount,matchingIdCount));
}

Fixed version (ground truth):
@Override public DataSet<Boolean> execute(GraphCollection<G,V,E> firstCollection,GraphCollection<G,V,E> secondCollection){
  DataSet<Tuple2<GradoopId,Long>> firstGraphIdsWithCount=getIdsWithCount(firstCollection);
  DataSet<Tuple2<GradoopId,Long>> secondGraphIdsWithCount=getIdsWithCount(secondCollection);
  DataSet<Long> distinctFirstIdCount=Count.count(firstGraphIdsWithCount);
  DataSet<Long> matchingIdCount=Count.count(firstGraphIdsWithCount.join(secondGraphIdsWithCount).where(0,1).equalTo(0,1));
  DataSet<Boolean> firstCollectionIsEmpty=firstCollection.isEmpty();
  return Or.union(And.cross(firstCollectionIsEmpty,secondCollection.isEmpty()),And.cross(Not.map(firstCollectionIsEmpty),Equals.cross(distinctFirstIdCount,matchingIdCount)));
}
Program: 95858
Project: 95858
Buggy source:
@Test public void testBasicStructuralEquality(){
  String asciiGraphs="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  FlinkAsciiGraphLoader<GraphHeadPojo,VertexPojo,EdgePojo> loader=getLoaderFromString(asciiGraphs);
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g1=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g2=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g3=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g4=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g5=loader.getLogicalGraphByVariable("String_Node_Str");
  EqualityByElementData<GraphHeadPojo,VertexPojo,EdgePojo> equals=new EqualityByElementData<>();
  collectAndAssertTrue(equals.execute(g1,g2));
  collectAndAssertFalse(equals.execute(g1,g3));
  collectAndAssertFalse(equals.execute(g1,g4));
  collectAndAssertFalse(equals.execute(g1,g5));
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> emptyGraph=LogicalGraph.createEmptyGraph(getConfig());
  collectAndAssertTrue(equals.execute(emptyGraph,emptyGraph));
  collectAndAssertFalse(equals.execute(g1,emptyGraph));
}

Fixed version (ground truth):
@Test public void testBasicStructuralEquality(){
  String asciiGraphs="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  FlinkAsciiGraphLoader<GraphHeadPojo,VertexPojo,EdgePojo> loader=getLoaderFromString(asciiGraphs);
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g1=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g2=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g3=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g4=loader.getLogicalGraphByVariable("String_Node_Str");
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> g5=loader.getLogicalGraphByVariable("String_Node_Str");
  EqualityByElementData<GraphHeadPojo,VertexPojo,EdgePojo> equals=new EqualityByElementData<>();
  collectAndAssertTrue(equals.execute(g1,g2));
  collectAndAssertFalse(equals.execute(g1,g3));
  collectAndAssertFalse(equals.execute(g1,g4));
  collectAndAssertFalse(equals.execute(g1,g5));
  LogicalGraph<GraphHeadPojo,VertexPojo,EdgePojo> emptyGraph=LogicalGraph.createEmptyGraph(getConfig());
  collectAndAssertTrue(equals.execute(emptyGraph,emptyGraph));
  collectAndAssertFalse(equals.execute(g1,emptyGraph));
  collectAndAssertFalse(equals.execute(emptyGraph,g1));
}
Program: 95862
Project: 95862
Buggy source:
@Test public void testExecute() throws Exception {
  EqualityByGraphElementIds<GraphHeadPojo,VertexPojo,EdgePojo> equals=new EqualityByGraphElementIds<>();
  String asciiGraphs="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  FlinkAsciiGraphLoader<GraphHeadPojo,VertexPojo,EdgePojo> loader=getLoaderFromString(asciiGraphs);
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c1=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c2=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c5=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  collectAndAssertTrue(equals.execute(c1,c2));
  collectAndAssertFalse(equals.execute(c1,c5));
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c3=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c4=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  collectAndAssertFalse(equals.execute(c3,c4));
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> emptyCollection=GraphCollection.createEmptyCollection(getConfig());
  collectAndAssertTrue(equals.execute(emptyCollection,emptyCollection));
  collectAndAssertFalse(equals.execute(c1,emptyCollection));
}

Fixed version (ground truth):
@Test public void testExecute() throws Exception {
  EqualityByGraphElementIds<GraphHeadPojo,VertexPojo,EdgePojo> equals=new EqualityByGraphElementIds<>();
  String asciiGraphs="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  FlinkAsciiGraphLoader<GraphHeadPojo,VertexPojo,EdgePojo> loader=getLoaderFromString(asciiGraphs);
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c1=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c2=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c5=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  collectAndAssertTrue(equals.execute(c1,c2));
  collectAndAssertFalse(equals.execute(c1,c5));
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c3=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c4=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  collectAndAssertFalse(equals.execute(c3,c4));
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> emptyCollection=GraphCollection.createEmptyCollection(getConfig());
  collectAndAssertTrue(equals.execute(emptyCollection,emptyCollection));
  collectAndAssertFalse(equals.execute(c1,emptyCollection));
  collectAndAssertFalse(equals.execute(emptyCollection,c1));
}
Program: 95863
Project: 95863
Buggy source:
@Test public void testEmpty(){
  String asciiGraphs="String_Node_Str";
  FlinkAsciiGraphLoader<GraphHeadPojo,VertexPojo,EdgePojo> loader=getLoaderFromString(asciiGraphs);
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c1=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c2=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c3=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  EqualityByGraphIds<GraphHeadPojo,VertexPojo,EdgePojo> equals=new EqualityByGraphIds<>();
  collectAndAssertTrue(equals.execute(c1,c2));
  collectAndAssertFalse(equals.execute(c1,c3));
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> emptyCollection=GraphCollection.createEmptyCollection(getConfig());
  collectAndAssertTrue(equals.execute(emptyCollection,emptyCollection));
  collectAndAssertFalse(equals.execute(c1,emptyCollection));
  collectAndAssertFalse(equals.execute(c3,emptyCollection));
}

Fixed version (ground truth):
@Test public void testEmpty(){
  String asciiGraphs="String_Node_Str";
  FlinkAsciiGraphLoader<GraphHeadPojo,VertexPojo,EdgePojo> loader=getLoaderFromString(asciiGraphs);
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c1=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c2=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> c3=loader.getGraphCollectionByVariables("String_Node_Str","String_Node_Str");
  EqualityByGraphIds<GraphHeadPojo,VertexPojo,EdgePojo> equals=new EqualityByGraphIds<>();
  collectAndAssertTrue(equals.execute(c1,c2));
  collectAndAssertFalse(equals.execute(c1,c3));
  GraphCollection<GraphHeadPojo,VertexPojo,EdgePojo> emptyCollection=GraphCollection.createEmptyCollection(getConfig());
  collectAndAssertTrue(equals.execute(emptyCollection,emptyCollection));
  collectAndAssertFalse(equals.execute(c1,emptyCollection));
  collectAndAssertFalse(equals.execute(c3,emptyCollection));
  collectAndAssertFalse(equals.execute(emptyCollection,c1));
}
Program: 95864
Project: 95864
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected LogicalGraph<G,V,E> executeInternal(LogicalGraph<G,V,E> firstGraph,LogicalGraph<G,V,E> secondGraph){
  DataSet<V> newVertexSet=firstGraph.getVertices().filter(new NotInGraphBroadcast<V>()).withBroadcastSet(secondGraph.getGraphHead(),NotInGraphBroadcast.GRAPH_ID);
  DataSet<E> newEdgeSet=firstGraph.getEdges().filter(new NotInGraphBroadcast<E>()).withBroadcastSet(secondGraph.getGraphHead(),NotInGraphBroadcast.GRAPH_ID);
  return LogicalGraph.fromDataSets(newVertexSet,newEdgeSet,firstGraph.getConfig());
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected LogicalGraph<G,V,E> executeInternal(LogicalGraph<G,V,E> firstGraph,LogicalGraph<G,V,E> secondGraph){
  DataSet<GradoopId> graphId=secondGraph.getGraphHead().map(new Id<G>());
  DataSet<V> newVertexSet=firstGraph.getVertices().filter(new NotInGraphBroadcast<V>()).withBroadcastSet(graphId,NotInGraphBroadcast.GRAPH_ID);
  DataSet<E> newEdgeSet=firstGraph.getEdges().filter(new NotInGraphBroadcast<E>()).withBroadcastSet(graphId,NotInGraphBroadcast.GRAPH_ID);
  return LogicalGraph.fromDataSets(newVertexSet,newEdgeSet,firstGraph.getConfig());
}
Program: 95865
Project: 95865
Buggy source:
@Override public boolean filter(Vertex<Long,VD> vertex) throws Exception {
  return randomGenerator.nextFloat() < threshold;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean filter(Vertex<Long,VD> vertex) throws Exception {
  return randomGenerator.nextFloat() < threshold;
}
Program: 95866
Project: 95866
Buggy source:
public VertexRandomFilter(Float sampleSize,Long randomSeed){
  threshold=sampleSize;
  randomGenerator=(randomSeed != null) ? new Random(randomSeed) : new Random();
}

Fixed version (ground truth):
/** 
 * Creates a new filter instance.
 * @param sampleSize relative sample size
 * @param randomSeed random seed (can be {@code} null)
 */
public VertexRandomFilter(Float sampleSize,Long randomSeed){
  threshold=sampleSize;
  randomGenerator=(randomSeed != null) ? new Random(randomSeed) : new Random();
}
Program: 95867
Project: 95867
Buggy source:
public RandomNodeSampling(Float sampleSize,Long randomSeed){
  this.sampleSize=sampleSize;
  this.randomSeed=randomSeed;
}

Fixed version (ground truth):
/** 
 * Creates new RandomNodeSampling instance.
 * @param sampleSize relative sample size
 * @param randomSeed random seed value (can be {@code null})
 */
public RandomNodeSampling(Float sampleSize,Long randomSeed){
  this.sampleSize=sampleSize;
  this.randomSeed=randomSeed;
}
Program: 95868
Project: 95868
Buggy source:
/** 
 * compute the new subgraphs created by the SplitBy
 * @param logicalGraph the input graph
 * @param vertices the computed vertices with their graphs
 * @return a DataSet containing all newly created subgraphs
 */
private DataSet<Subgraph<Long,GD>> computeNewSubgraphs(LogicalGraph<VD,ED,GD> logicalGraph,DataSet<Vertex<Long,VD>> vertices){
  KeySelector<Vertex<Long,VD>,Long> propertySelector=new LongFromVertexSelector<>(function);
  GraphDataFactory<GD> gdFactory=logicalGraph.getGraphDataFactory();
  return vertices.groupBy(propertySelector).reduceGroup(new SubgraphsFromGroupsReducer<>(function,gdFactory));
}

Fixed version (ground truth):
/** 
 * compute the new subgraphs created by the SplitBy
 * @param logicalGraph the input graph
 * @param vertices     the computed vertices with their graphs
 * @return a DataSet containing all newly created subgraphs
 */
private DataSet<Subgraph<Long,GD>> computeNewSubgraphs(LogicalGraph<VD,ED,GD> logicalGraph,DataSet<Vertex<Long,VD>> vertices){
  KeySelector<Vertex<Long,VD>,Long> propertySelector=new LongFromVertexSelector<>(function);
  GraphDataFactory<GD> gdFactory=logicalGraph.getGraphDataFactory();
  return vertices.groupBy(propertySelector).reduceGroup(new SubgraphsFromGroupsReducer<>(function,gdFactory));
}
Program: 95869
Project: 95869
Buggy source:
/** 
 * compute the edges which source and target are in the same newly created graph
 * @param logicalGraph the input graph
 * @param vertices the computed vertices with their graphs
 * @param subgraphs the computed subgraphs
 * @return a DataSet containing all newly created edges, each edge has anew graph in its graph set
 */
private DataSet<Edge<Long,ED>> computeNewEdges(LogicalGraph<VD,ED,GD> logicalGraph,DataSet<Vertex<Long,VD>> vertices,DataSet<Subgraph<Long,GD>> subgraphs){
  final Graph<Long,VD,ED> graph=logicalGraph.getGellyGraph();
  DataSet<Tuple3<Long,Long,Long>> edgeVertexVertex=graph.getEdges().map(new EdgeToTupleMapper<ED>());
  DataSet<Tuple3<Long,Set<Long>,Long>> edgeGraphsVertex=edgeVertexVertex.join(vertices).where(1).equalTo(0).with(new JoinEdgeTupleWithSourceGraphs<VD>());
  DataSet<Tuple3<Long,Set<Long>,Set<Long>>> edgeGraphsGraphs=edgeGraphsVertex.join(vertices).where(2).equalTo(0).with(new JoinEdgeTupleWithTargetGraphs<VD>());
  DataSet<Set<Long>> newSubgraphIdentifiers=subgraphs.map(new MapSubgraphIdToSet<GD>()).reduce(new ReduceSets());
  DataSet<Tuple4<Long,Set<Long>,Set<Long>,Set<Long>>> edgesWithSubgraphs=edgeGraphsGraphs.crossWithTiny(newSubgraphIdentifiers).with(new CrossEdgesWithGraphSet());
  DataSet<Tuple2<Long,Set<Long>>> newSubgraphs=edgesWithSubgraphs.flatMap(new CheckEdgesSourceTargetGraphs());
  return graph.getEdges().join(newSubgraphs).where(new KeySelectors.EdgeKeySelector<ED>()).equalTo(0).with(new JoinEdgeTuplesWithEdges<ED>());
}

Fixed version (ground truth):
/** 
 * compute the edges which source and target are in the same newly created graph
 * @param logicalGraph the input graph
 * @param vertices     the computed vertices with their graphs
 * @param subgraphs    the computed subgraphs
 * @return a DataSet containing all newly created edges, each edge has anew graph in its graph set
 */
private DataSet<Edge<Long,ED>> computeNewEdges(LogicalGraph<VD,ED,GD> logicalGraph,DataSet<Vertex<Long,VD>> vertices,DataSet<Subgraph<Long,GD>> subgraphs){
  final Graph<Long,VD,ED> graph=logicalGraph.getGellyGraph();
  DataSet<Tuple3<Long,Long,Long>> edgeVertexVertex=graph.getEdges().map(new EdgeToTupleMapper<ED>());
  DataSet<Tuple3<Long,Set<Long>,Long>> edgeGraphsVertex=edgeVertexVertex.join(vertices).where(1).equalTo(0).with(new JoinEdgeTupleWithSourceGraphs<VD>());
  DataSet<Tuple3<Long,Set<Long>,Set<Long>>> edgeGraphsGraphs=edgeGraphsVertex.join(vertices).where(2).equalTo(0).with(new JoinEdgeTupleWithTargetGraphs<VD>());
  DataSet<Set<Long>> newSubgraphIdentifiers=subgraphs.map(new MapSubgraphIdToSet<GD>()).reduce(new ReduceSets());
  DataSet<Tuple4<Long,Set<Long>,Set<Long>,Set<Long>>> edgesWithSubgraphs=edgeGraphsGraphs.crossWithTiny(newSubgraphIdentifiers).with(new CrossEdgesWithGraphSet());
  DataSet<Tuple2<Long,Set<Long>>> newSubgraphs=edgesWithSubgraphs.flatMap(new CheckEdgesSourceTargetGraphs());
  return graph.getEdges().join(newSubgraphs).where(new KeySelectors.EdgeKeySelector<ED>()).equalTo(0).with(new JoinEdgeTuplesWithEdges<ED>());
}
Program: 95870
Project: 95870
Buggy source:
private void initList(){
  if (partitionHistory == null) {
    this.partitionHistory=Lists.newArrayList();
  }
}

Fixed version (ground truth):
/** 
 * Initialize the PartitionHistoryList
 */
private void initList(){
  if (partitionHistory == null) {
    this.partitionHistory=Lists.newArrayList();
  }
}
Program: 95871
Project: 95871
Buggy source:
/** 
 * Method to add a partition to partition history
 */
public void addToPartitionHistory(int partition){
  initList();
  this.partitionHistory.add(partition);
}

Fixed version (ground truth):
/** 
 * Method to add a partition to partition history
 * @param partition the vertex had
 */
public void addToPartitionHistory(int partition){
  initList();
  this.partitionHistory.add(partition);
}
Program: 95873
Project: 95873
Buggy source:
private GiraphConfiguration getConfiguration(){
  GiraphConfiguration conf=new GiraphConfiguration();
  conf.setComputationClass(KwayPartitioningComputation.class);
  conf.setMasterComputeClass(KwayPartitioningMasterComputation.class);
  conf.setVertexInputFormatClass(IntIntNullTextVertexInputFormat.class);
  conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
  return conf;
}

Fixed version (ground truth):
private GiraphConfiguration getConfiguration(){
  GiraphConfiguration conf=new GiraphConfiguration();
  conf.setComputationClass(KwayPartitioningComputation.class);
  conf.setMasterComputeClass(KwayPartitioningMasterComputation.class);
  conf.setVertexInputFormatClass(KwayPartitioningInputFormat.class);
  conf.setVertexOutputFormatClass(KwayPartitioningOutputFormat.class);
  return conf;
}
Program: 95874
Project: 95874
Buggy source:
@Test public void testSmallConnectedGraph() throws Exception {
  String[] graph=PartitioningComputationTestHelper.getKwaySmallConnectedGraph();
  validateSmallConnectedGraphResult(computeResults(graph,2));
}

Fixed version (ground truth):
@Test public void testSmallConnectedGraph() throws Exception {
  String[] graph=PartitioningComputationTestHelper.getKwaySmallConnectedGraph();
  validateSmallConnectedGraphResult(computeResults(graph,3));
}
Program: 95875
Project: 95875
Buggy source:
/** 
 * The actual KwayPartitioning Computation
 * @param vertex   Vertex
 * @param messages Messages that were sent to this vertex in the previoussuperstep.
 * @throws IOException
 */
@Override public void compute(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages) throws IOException {
  if (getSuperstep() == 0) {
    setVertexStartValue(vertex);
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + vertex.getValue().getCurrentVertexValue().get();
    notifyCapacityAggregator(aggregator,1);
    sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
    vertex.voteToHalt();
  }
 else {
    if ((getSuperstep() % 2) == 0) {
      int desiredPartition=vertex.getValue().getLastVertexValue().get();
      boolean migrate=calculateThreshold(desiredPartition);
      if (migrate) {
        migrateVertex(vertex,desiredPartition);
        sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
      }
 else {
        vertex.voteToHalt();
      }
    }
 else     if ((getSuperstep() % 2) == 1) {
      int desiredPartition=getDesiredPartition(vertex,messages);
      vertex.getValue().setLastVertexValue(new IntWritable(desiredPartition));
      int currentValue=vertex.getValue().getCurrentVertexValue().get();
      boolean changed=currentValue != desiredPartition;
      if (changed) {
        notifyDemandAggregator(desiredPartition);
        vertex.voteToHalt();
      }
    }
  }
  vertex.voteToHalt();
}

Fixed version (ground truth):
/** 
 * The actual KwayPartitioning Computation
 * @param vertex   Vertex
 * @param messages Messages that were sent to this vertex in the previoussuperstep.
 * @throws IOException
 */
@Override public void compute(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages) throws IOException {
  k=Integer.valueOf(getConf().get(NUMBER_OF_PARTITIONS));
  if (getSuperstep() == 0) {
    setVertexStartValue(vertex);
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + vertex.getValue().getCurrentVertexValue().get();
    notifyCapacityAggregator(aggregator,1);
    sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
    vertex.voteToHalt();
  }
 else {
    if ((getSuperstep() % 2) == 0) {
      int desiredPartition=vertex.getValue().getLastVertexValue().get();
      boolean migrate=doMigrate(desiredPartition);
      if (migrate) {
        migrateVertex(vertex,desiredPartition);
        sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
      }
    }
 else     if ((getSuperstep() % 2) == 1) {
      int desiredPartition=getDesiredPartition(vertex,messages);
      vertex.getValue().setLastVertexValue(new IntWritable(desiredPartition));
      int currentValue=vertex.getValue().getCurrentVertexValue().get();
      boolean changed=currentValue != desiredPartition;
      if (changed) {
        notifyDemandAggregator(desiredPartition);
      }
    }
  }
  vertex.voteToHalt();
}
Program: 95876
Project: 95876
Buggy source:
private Map<Integer,Double> getPartitionWeight(Map<Integer,Integer> countNeighbours){
  Map<Integer,Double> partitionWeight=new HashMap<>();
  double partitionCount=Double.valueOf(getConf().get(NUMBER_OF_PARTITIONS));
  double totalNeighbours=countNeighbours.size();
  for (int i=0; i < partitionCount; i++) {
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + i;
    IntWritable aggregator_load=getAggregatedValue(aggregator);
    double load=aggregator_load.get();
    double numNeighboursInI=countNeighbours.get(i);
    double weight=numNeighboursInI / (load * totalNeighbours);
    partitionWeight.put(i,weight);
  }
  return partitionWeight;
}

Fixed version (ground truth):
private double[] getPartitionWeight(int[] partitionCount,int numEdges){
  double[] partitionWeights=new double[k];
  for (int i=0; i < k; i++) {
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + i;
    IntWritable aggregator_load=getAggregatedValue(aggregator);
    double load=aggregator_load.get();
    double numNeighboursInI=partitionCount[i];
    double weight=numNeighboursInI / (load * numEdges);
    partitionWeights[i]=weight;
  }
  return partitionWeights;
}
Program: 95877
Project: 95877
Buggy source:
private int getDesiredPartition(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages){
  int desiredPartition=0;
  Map<Integer,Integer> countNeighbours=getCountNeighbours(messages);
  if (countNeighbours.size() != 0) {
    Map<Integer,Double> partitionWeight=getPartitionWeight(countNeighbours);
    double highestWeight=0;
    for (    Map.Entry<Integer,Double> entry : partitionWeight.entrySet()) {
      if (Double.compare(highestWeight,entry.getValue()) < 0) {
        desiredPartition=entry.getKey();
        highestWeight=entry.getValue();
      }
    }
  }
 else {
    return vertex.getValue().getCurrentVertexValue().get();
  }
  return desiredPartition;
}

Fixed version (ground truth):
private int getDesiredPartition(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages){
  int currentPartition=vertex.getValue().getCurrentVertexValue().get();
  int desiredPartition=currentPartition;
  if (messages.iterator().hasNext()) {
    int[] countNeighbours=getCountNeighbours(messages);
    double[] partitionWeights=getPartitionWeight(countNeighbours,vertex.getNumEdges());
    double firstMax=Integer.MIN_VALUE;
    double secondMax=Integer.MIN_VALUE;
    int firstK=-1;
    int secondK=-1;
    for (int i=0; i < k; i++) {
      if (partitionWeights[i] >= firstMax) {
        secondMax=firstMax;
        firstMax=countNeighbours[i];
        secondK=firstK;
        firstK=i;
      }
    }
    if (firstMax == secondMax) {
      if (currentPartition != firstK && currentPartition != secondK) {
        desiredPartition=firstK;
      }
    }
 else {
      desiredPartition=firstK;
    }
  }
  return desiredPartition;
}
Program: 95878
Project: 95878
Buggy source:
private Map<Integer,Integer> getCountNeighbours(Iterable<IntWritable> messages){
  Map<Integer,Integer> countNeighbours=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);
    }
  }
  return countNeighbours;
}

Fixed version (ground truth):
private int[] getCountNeighbours(Iterable<IntWritable> messages){
  int[] countNeighbours=new int[k];
  for (  IntWritable message : messages) {
    int partition=message.get();
    countNeighbours[partition]++;
  }
  return countNeighbours;
}
Program: 95879
Project: 95879
Buggy source:
private void notifyDemandAggregator(int desiredPartition){
  String aggregator=KWAY_DEMAND_AGGREGATOR_PREFIX + desiredPartition;
  aggregate(aggregator,new IntWritable(1));
}

Fixed version (ground truth):
private void notifyDemandAggregator(int desiredPartition){
  String aggregator=KWAY_DEMAND_AGGREGATOR_PREFIX + desiredPartition;
  aggregate(aggregator,ONE);
}
Program: 95880
Project: 95880
Buggy source:
private void validateSmallConnectedGraphResult(Map<Integer,Integer> vertexIDwithValue){
  assertEquals(8,vertexIDwithValue.size());
  assertEquals(0,vertexIDwithValue.get(0).intValue());
  assertEquals(0,vertexIDwithValue.get(1).intValue());
  assertEquals(0,vertexIDwithValue.get(2).intValue());
  assertEquals(0,vertexIDwithValue.get(3).intValue());
  assertEquals(1,vertexIDwithValue.get(4).intValue());
  assertEquals(1,vertexIDwithValue.get(5).intValue());
  assertEquals(1,vertexIDwithValue.get(6).intValue());
  assertEquals(1,vertexIDwithValue.get(7).intValue());
}

Fixed version (ground truth):
private void validateSmallConnectedGraphResult(Map<Integer,Integer> vertexIDwithValue){
  assertEquals(8,vertexIDwithValue.size());
  assertEquals(0,vertexIDwithValue.get(0).intValue());
  assertEquals(1,vertexIDwithValue.get(1).intValue());
  assertEquals(0,vertexIDwithValue.get(2).intValue());
  assertEquals(1,vertexIDwithValue.get(3).intValue());
  assertEquals(0,vertexIDwithValue.get(4).intValue());
  assertEquals(1,vertexIDwithValue.get(5).intValue());
  assertEquals(0,vertexIDwithValue.get(6).intValue());
  assertEquals(1,vertexIDwithValue.get(7).intValue());
}
Program: 95881
Project: 95881
Buggy source:
@Test public void testSmallConnectedGraph() throws Exception {
  String[] graph=PartitioningComputationTestHelper.getLPConnectedGraph();
  validateSmallConnectedGraphResult(computeResults(graph,2));
}

Fixed version (ground truth):
@Test public void testSmallConnectedGraph() throws Exception {
  String[] graph=PartitioningComputationTestHelper.getKwaySmallConnectedGraph();
  validateSmallConnectedGraphResult(computeResults(graph,2,100));
}
Program: 95882
Project: 95882
Buggy source:
private Map<Integer,Integer> computeResults(String[] graph,int partitionCount) throws Exception {
  GiraphConfiguration conf=getConfiguration();
  conf.set(KwayPartitioningComputation.NUMBER_OF_PARTITIONS,Integer.toString(partitionCount));
  Iterable<String> results=InternalVertexRunner.run(conf,graph);
  return parseResults(results);
}

Fixed version (ground truth):
private Map<Integer,Integer> computeResults(String[] graph,int partitionCount,int max_iteration) throws Exception {
  GiraphConfiguration conf=getConfiguration();
  conf.set(KwayPartitioningComputation.NUMBER_OF_PARTITIONS,Integer.toString(partitionCount));
  conf.set(KwayPartitioningComputation.NUMBER_OF_ITERATIONS,Integer.toString(max_iteration));
  Iterable<String> results=InternalVertexRunner.run(conf,graph);
  return parseResults(results);
}
Program: 95883
Project: 95883
Buggy source:
private Map<Integer,Integer> parseResults(Iterable<String> results){
  Map<Integer,Integer> parsedResults=Maps.newHashMap();
  String[] lineTokens;
  int value;
  int vertexID;
  for (  String line : results) {
    lineTokens=LINE_TOKEN_SEPARATOR.split(line);
    vertexID=Integer.parseInt(lineTokens[0]);
    value=Integer.parseInt(lineTokens[1]);
    parsedResults.put(vertexID,value);
  }
  return parsedResults;
}

Fixed version (ground truth):
private Map<Integer,Integer> parseResults(Iterable<String> results){
  Map<Integer,Integer> parsedResults=Maps.newHashMap();
  String[] lineTokens;
  int value;
  int vertexID;
  for (  String line : results) {
    lineTokens=LINE_TOKEN_SEPARATOR.split(line);
    vertexID=Integer.parseInt(lineTokens[0]);
    System.out.println(line);
    value=Integer.parseInt(lineTokens[1]);
    parsedResults.put(vertexID,value);
  }
  return parsedResults;
}
Program: 95884
Project: 95884
Buggy source:
private void setVertexStartValue(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex){
  int partitionCount=Integer.valueOf(getConf().get(NUMBER_OF_PARTITIONS));
  int startValue=vertex.getId().get() % partitionCount;
  vertex.getValue().setCurrentVertexValue(new IntWritable(startValue));
  vertex.getValue().setLastVertexValue(vertex.getValue().getCurrentVertexValue());
}

Fixed version (ground truth):
private void setVertexStartValue(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex){
  int partitionCount=Integer.valueOf(getConf().get(NUMBER_OF_PARTITIONS));
  int startValue=vertex.getId().get() % partitionCount;
  vertex.getValue().setCurrentVertexValue(new IntWritable(startValue));
}
Program: 95885
Project: 95885
Buggy source:
/** 
 * The actual KwayPartitioning Computation
 * @param vertex   Vertex
 * @param messages Messages that were sent to this vertex in the previoussuperstep.
 * @throws IOException
 */
@Override public void compute(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages) throws IOException {
  String computation_case=String.valueOf(getConf().get(COMPUTATION_CASE));
  int nodecount=0;
  if (getSuperstep() == 0) {
    setVertexStartValue(vertex);
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + vertex.getValue().getCurrentVertexValue().get();
    notifyCapacityAggregator(aggregator,1);
    sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
    vertex.voteToHalt();
  }
 else {
    if ((getSuperstep() % 2) == 0) {
      int desiredPartition=getHighestWeight(vertex,messages);
      boolean migrate=calculateThreshold(desiredPartition);
      if (migrate) {
        migrateVertex(vertex,desiredPartition);
        sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
      }
 else {
        vertex.voteToHalt();
      }
    }
 else {
      int desiredPartition=getHighestWeight(vertex,messages);
      int currentValue=vertex.getValue().getCurrentVertexValue().get();
      boolean changed=currentValue != desiredPartition;
      if (changed) {
        notifyDemandAggregator(desiredPartition);
      }
 else {
        vertex.voteToHalt();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * The actual KwayPartitioning Computation
 * @param vertex   Vertex
 * @param messages Messages that were sent to this vertex in the previoussuperstep.
 * @throws IOException
 */
@Override public void compute(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,Iterable<IntWritable> messages) throws IOException {
  if (getSuperstep() == 0) {
    setVertexStartValue(vertex);
    String aggregator=KWAY_CAPACITY_AGGREGATOR_PREFIX + vertex.getValue().getCurrentVertexValue().get();
    notifyCapacityAggregator(aggregator,1);
    sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
    vertex.voteToHalt();
  }
 else {
    if ((getSuperstep() % 2) == 0) {
      int desiredPartition=vertex.getValue().getLastVertexValue().get();
      boolean migrate=calculateThreshold(desiredPartition);
      if (migrate) {
        migrateVertex(vertex,desiredPartition);
        sendMessageToAllEdges(vertex,vertex.getValue().getCurrentVertexValue());
      }
 else {
        vertex.voteToHalt();
      }
    }
 else     if ((getSuperstep() % 2) == 1) {
      int desiredPartition=getHighestWeight(vertex,messages);
      vertex.getValue().setLastVertexValue(new IntWritable(desiredPartition));
      int currentValue=vertex.getValue().getCurrentVertexValue().get();
      boolean changed=currentValue != desiredPartition;
      if (changed) {
        notifyDemandAggregator(desiredPartition);
      }
 else {
        vertex.voteToHalt();
      }
    }
  }
  vertex.voteToHalt();
}
Program: 95887
Project: 95887
Buggy source:
private GiraphConfiguration getConfiguration(){
  GiraphConfiguration conf=new GiraphConfiguration();
  conf.setComputationClass(KwayPartitioningComputation.class);
  conf.setMasterComputeClass(KwayPartitioningMasterComputation.class);
  conf.setVertexInputFormatClass(KwayPartitioningInputFormat.class);
  conf.setVertexOutputFormatClass(KwayPartitioningOutputFormat.class);
  return conf;
}

Fixed version (ground truth):
private GiraphConfiguration getConfiguration(){
  GiraphConfiguration conf=new GiraphConfiguration();
  conf.setComputationClass(KwayPartitioningComputation.class);
  conf.setMasterComputeClass(KwayPartitioningMasterComputation.class);
  conf.setVertexInputFormatClass(IntIntNullTextVertexInputFormat.class);
  conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
  return conf;
}
Program: 95888
Project: 95888
Buggy source:
private void validateSmallConnectedGraphResult(Map<Integer,Integer> vertexIDwithValue){
  if (0 == vertexIDwithValue.get(0)) {
    if (1 == vertexIDwithValue.get(4)) {
      assertEquals(8,vertexIDwithValue.size());
      assertEquals(0,vertexIDwithValue.get(0).intValue());
      assertEquals(0,vertexIDwithValue.get(1).intValue());
      assertEquals(0,vertexIDwithValue.get(2).intValue());
      assertEquals(0,vertexIDwithValue.get(3).intValue());
      assertEquals(1,vertexIDwithValue.get(4).intValue());
      assertEquals(1,vertexIDwithValue.get(5).intValue());
      assertEquals(1,vertexIDwithValue.get(6).intValue());
      assertEquals(1,vertexIDwithValue.get(7).intValue());
    }
  }
  if (1 == vertexIDwithValue.get(0)) {
    if (0 == vertexIDwithValue.get(4)) {
      assertEquals(8,vertexIDwithValue.size());
      assertEquals(1,vertexIDwithValue.get(0).intValue());
      assertEquals(1,vertexIDwithValue.get(1).intValue());
      assertEquals(1,vertexIDwithValue.get(2).intValue());
      assertEquals(1,vertexIDwithValue.get(4).intValue());
      assertEquals(0,vertexIDwithValue.get(5).intValue());
      assertEquals(0,vertexIDwithValue.get(6).intValue());
      assertEquals(0,vertexIDwithValue.get(7).intValue());
      assertEquals(0,vertexIDwithValue.get(8).intValue());
    }
  }
}

Fixed version (ground truth):
private void validateSmallConnectedGraphResult(Map<Integer,Integer> vertexIDwithValue){
  assertEquals(8,vertexIDwithValue.size());
  assertEquals(0,vertexIDwithValue.get(0).intValue());
  assertEquals(0,vertexIDwithValue.get(1).intValue());
  assertEquals(0,vertexIDwithValue.get(2).intValue());
  assertEquals(0,vertexIDwithValue.get(3).intValue());
  assertEquals(1,vertexIDwithValue.get(4).intValue());
  assertEquals(1,vertexIDwithValue.get(5).intValue());
  assertEquals(1,vertexIDwithValue.get(6).intValue());
  assertEquals(1,vertexIDwithValue.get(7).intValue());
}
Program: 95889
Project: 95889
Buggy source:
@Test public void testSmallConnectedGraph() throws Exception {
  String[] graph=PartitioningComputationTestHelper.getKwaySmallConnectedGraph();
  validateSmallConnectedGraphResult(computeResults(graph,2,"String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testSmallConnectedGraph() throws Exception {
  String[] graph=PartitioningComputationTestHelper.getKwaySmallConnectedGraph();
  validateSmallConnectedGraphResult(computeResults(graph,2));
}
Program: 95890
Project: 95890
Buggy source:
private Map<Integer,Integer> computeResults(String[] graph,int partitionCount,String computation_case) throws Exception {
  GiraphConfiguration conf=getConfiguration();
  conf.set(KwayPartitioningComputation.NUMBER_OF_PARTITIONS,Integer.toString(partitionCount));
  conf.set(KwayPartitioningComputation.COMPUTATION_CASE,computation_case);
  Iterable<String> results=InternalVertexRunner.run(conf,graph);
  return parseResults(results);
}

Fixed version (ground truth):
private Map<Integer,Integer> computeResults(String[] graph,int partitionCount) throws Exception {
  GiraphConfiguration conf=getConfiguration();
  conf.set(KwayPartitioningComputation.NUMBER_OF_PARTITIONS,Integer.toString(partitionCount));
  Iterable<String> results=InternalVertexRunner.run(conf,graph);
  return parseResults(results);
}
Program: 95891
Project: 95891
Buggy source:
/** 
 * Returns the most frequent value based on all received messages.
 * @param vertex      The current vertex
 * @param allMessages All messages the current vertex has received
 * @return the maximal frequent number in all received messages
 */
private int getMostFrequent(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,List<Integer> allMessages){
  Collections.sort(allMessages);
  int newValue;
  int currentCounter=1;
  int currentValue=allMessages.get(0);
  int maxCounter=1;
  int maxValue=1;
  for (int i=1; i < allMessages.size(); i++) {
    if (currentValue == allMessages.get(i)) {
      currentCounter++;
      if (maxCounter < currentCounter) {
        maxCounter=currentCounter;
        maxValue=currentValue;
      }
    }
 else {
      currentCounter=1;
      currentValue=allMessages.get(i);
    }
  }
  if (maxCounter == 1) {
switch (computation_case) {
case "String_Node_Str":
      newValue=getSwitchValue(allMessages.get(0),vertex);
    break;
case "String_Node_Str":
  newValue=getSwitchValue(allMessages.get(allMessages.size() - 1),vertex);
break;
case "String_Node_Str":
newValue=getSwitchValue(allMessages.get(new Random().nextInt(allMessages.size() - 1)),vertex);
default :
newValue=getSwitchValue(allMessages.get(0),vertex);
}
}
 else {
newValue=getSwitchValue(maxValue,vertex);
}
return newValue;
}

Fixed version (ground truth):
/** 
 * Returns the most frequent value based on all received messages.
 * @param vertex      The current vertex
 * @param allMessages All messages the current vertex has received
 * @return the maximal frequent number in all received messages
 */
private int getMostFrequent(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,List<Integer> allMessages){
  Collections.sort(allMessages);
  int newValue;
  int currentCounter=1;
  int currentValue=allMessages.get(0);
  int maxCounter=1;
  int maxValue=1;
  for (int i=1; i < allMessages.size(); i++) {
    if (currentValue == allMessages.get(i)) {
      currentCounter++;
      if (maxCounter < currentCounter) {
        maxCounter=currentCounter;
        maxValue=currentValue;
      }
    }
 else {
      currentCounter=1;
      currentValue=allMessages.get(i);
    }
  }
  if (maxCounter == 1) {
switch (computation_case) {
case "String_Node_Str":
      newValue=getSwitchValue(allMessages.get(0),vertex);
    break;
case "String_Node_Str":
  newValue=getSwitchValue(allMessages.get(allMessages.size() - 1),vertex);
break;
case "String_Node_Str":
newValue=getSwitchValue(allMessages.get(new Random().nextInt(allMessages.size() - 1)),vertex);
break;
default :
newValue=getSwitchValue(allMessages.get(0),vertex);
}
}
 else {
newValue=getSwitchValue(maxValue,vertex);
}
return newValue;
}
Program: 95892
Project: 95892
Buggy source:
/** 
 * Decides how the computation should work in different cases.
 * @param value1 int value to compare with
 * @param vertex The current vertex
 * @return new vertex value
 */
public int getSwitchValue(int value1,Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex){
  int value;
switch (computation_case) {
case "String_Node_Str":
    value=Math.min(value1,vertex.getValue().getLastVertexValue().get());
  break;
case "String_Node_Str":
value=Math.max(value1,vertex.getValue().getCurrentVertexValue().get());
break;
case "String_Node_Str":
if (value1 == vertex.getValue().getLastVertexValue().get()) {
value=vertex.getValue().getLastVertexValue().get();
}
 else {
value=Math.min(value1,vertex.getValue().getLastVertexValue().get());
break;
}
default :
value=Math.min(value1,vertex.getValue().getCurrentVertexValue().get());
}
return value;
}

Fixed version (ground truth):
/** 
 * Decides how the computation should work in different cases.
 * @param value1 int value to compare with
 * @param vertex The current vertex
 * @return new vertex value
 */
public int getSwitchValue(int value1,Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex){
  int value;
switch (computation_case) {
case "String_Node_Str":
    value=Math.min(value1,vertex.getValue().getLastVertexValue().get());
  break;
case "String_Node_Str":
value=Math.max(value1,vertex.getValue().getCurrentVertexValue().get());
break;
case "String_Node_Str":
if (value1 == vertex.getValue().getLastVertexValue().get()) {
value=vertex.getValue().getLastVertexValue().get();
}
 else {
value=Math.min(value1,vertex.getValue().getLastVertexValue().get());
}
break;
default :
value=Math.min(value1,vertex.getValue().getCurrentVertexValue().get());
}
return value;
}
Program: 95893
Project: 95893
Buggy source:
/** 
 * Returns the most frequent value based on all received messages.
 * @param vertex      The current vertex
 * @param allMessages All messages the current vertex has received
 * @return the maximal frequent number in all received messages
 */
private int getMostFrequent(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,List<Integer> allMessages){
  Collections.sort(allMessages);
  int newValue;
  int currentCounter=1;
  int currentValue=allMessages.get(0);
  int maxCounter=1;
  int maxValue=1;
  for (int i=1; i < allMessages.size(); i++) {
    if (currentValue == allMessages.get(i)) {
      currentCounter++;
      if (maxCounter < currentCounter) {
        maxCounter=currentCounter;
        maxValue=currentValue;
      }
    }
 else {
      currentCounter=1;
      currentValue=allMessages.get(i);
    }
  }
  if (maxCounter == 1) {
    newValue=getSwitchValue(allMessages.get(allMessages.size() - 1),vertex);
  }
 else {
    newValue=getSwitchValue(maxValue,vertex);
  }
  return newValue;
}

Fixed version (ground truth):
/** 
 * Returns the most frequent value based on all received messages.
 * @param vertex      The current vertex
 * @param allMessages All messages the current vertex has received
 * @return the maximal frequent number in all received messages
 */
private int getMostFrequent(Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex,List<Integer> allMessages){
  Collections.sort(allMessages);
  int newValue;
  int currentCounter=1;
  int currentValue=allMessages.get(0);
  int maxCounter=1;
  int maxValue=1;
  for (int i=1; i < allMessages.size(); i++) {
    if (currentValue == allMessages.get(i)) {
      currentCounter++;
      if (maxCounter < currentCounter) {
        maxCounter=currentCounter;
        maxValue=currentValue;
      }
    }
 else {
      currentCounter=1;
      currentValue=allMessages.get(i);
    }
  }
  if (maxCounter == 1) {
switch (computation_case) {
case "String_Node_Str":
      newValue=getSwitchValue(allMessages.get(0),vertex);
    break;
case "String_Node_Str":
  newValue=getSwitchValue(allMessages.get(allMessages.size() - 1),vertex);
break;
case "String_Node_Str":
newValue=getSwitchValue(allMessages.get(new Random().nextInt(allMessages.size() - 1)),vertex);
default :
newValue=getSwitchValue(allMessages.get(0),vertex);
}
}
 else {
newValue=getSwitchValue(maxValue,vertex);
}
return newValue;
}
Program: 95894
Project: 95894
Buggy source:
public int getSwitchValue(int value1,Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex){
  int value;
  if (value1 == vertex.getValue().getLastVertexValue().get()) {
    value=vertex.getValue().getCurrentVertexValue().get();
  }
 else {
switch (computation_case) {
case "String_Node_Str":
      value=Math.min(value1,vertex.getValue().getCurrentVertexValue().get());
    break;
case "String_Node_Str":
  value=Math.max(value1,vertex.getValue().getCurrentVertexValue().get());
break;
case "String_Node_Str":
if (1 == new Random().nextInt(2)) {
value=value1;
}
 else {
value=vertex.getValue().getCurrentVertexValue().get();
}
break;
default :
value=Math.min(value1,vertex.getValue().getCurrentVertexValue().get());
}
}
return value;
}

Fixed version (ground truth):
/** 
 * Decides how the computation should work in different cases.
 * @param value1 int value to compare with
 * @param vertex The current vertex
 * @return new vertex value
 */
public int getSwitchValue(int value1,Vertex<IntWritable,KwayPartitioningVertex,NullWritable> vertex){
  int value;
switch (computation_case) {
case "String_Node_Str":
    value=Math.min(value1,vertex.getValue().getLastVertexValue().get());
  break;
case "String_Node_Str":
value=Math.max(value1,vertex.getValue().getCurrentVertexValue().get());
break;
case "String_Node_Str":
if (value1 == vertex.getValue().getLastVertexValue().get()) {
value=vertex.getValue().getLastVertexValue().get();
}
 else {
value=Math.min(value1,vertex.getValue().getLastVertexValue().get());
break;
}
default :
value=Math.min(value1,vertex.getValue().getCurrentVertexValue().get());
}
return value;
}