nus-yam/ex-repair huggingface dataset:
Program: 51001
Project: 51001
Buggy source:
@Override protected void setup(){
  directed=graph instanceof DGraph<?>;
  if (size.equals("String_Node_Str"))   experiments.add(new HugeGraph<N>(graph));
 else   if (size.equals("String_Node_Str"))   experiments.add(new LargeGraph<N>(graph));
 else   if (size.equals("String_Node_Str"))   experiments.add(new SmallGraph<N>(graph));
 else   throw new RuntimeException("String_Node_Str" + size + "String_Node_Str");
  if (!size.equals("String_Node_Str"))   experiments.add(new GraphDimension<N>(graph,1,6,"String_Node_Str"));
}

Fixed version (ground truth):
@Override protected void setup(){
  directed=graph instanceof DGraph<?>;
  if (size.equals("String_Node_Str"))   experiments.add(new HugeGraph<N>(graph));
 else   if (size.equals("String_Node_Str"))   experiments.add(new LargeGraph<N>(graph));
 else   if (size.equals("String_Node_Str"))   experiments.add(new SmallGraph<N>(graph));
 else   throw new RuntimeException("String_Node_Str" + size + "String_Node_Str");
  experiments.add(new GraphDimension<N>(graph,1,6,"String_Node_Str"));
}
Program: 51004
Project: 51004
Buggy source:
/** 
 * Second step in the WL algorithm. We compress the long labels into new short labels
 * @param graphs
 * @param labelDict
 * @param currentLabel
 * @return
 */
private int compressGraphLabels(List<DirectedGraph<Vertex<String>,Edge<String>>> graphs,Map<String,String> labelDict,int currentLabel){
  String label;
  for (  DirectedGraph<Vertex<String>,Edge<String>> graph : graphs) {
    for (    Edge<String> edge : graph.getEdges()) {
      label=labelDict.get(edge.getLabel());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(edge.getLabel(),label);
      }
      edge.setLabel(label);
    }
    for (    Vertex<String> vertex : graph.getVertices()) {
      label=labelDict.get(vertex.getLabel());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(vertex.getLabel(),label);
      }
      vertex.setLabel(label);
    }
  }
  return currentLabel;
}

Fixed version (ground truth):
/** 
 * Second step in the WL algorithm. We compress the long labels into new short labels
 * @param graphs
 * @param labelDict
 * @param currentLabel
 * @return
 */
private int compressGraphLabels(List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs,Map<String,String> labelDict,int currentLabel){
  String label;
  for (  DirectedGraph<Vertex<StringBuffer>,Edge<StringBuffer>> graph : graphs) {
    for (    Edge<StringBuffer> edge : graph.getEdges()) {
      label=labelDict.get(edge.getLabel());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(edge.getLabel().toString(),label);
      }
      edge.setLabel(new StringBuffer(label));
    }
    for (    Vertex<StringBuffer> vertex : graph.getVertices()) {
      label=labelDict.get(vertex.getLabel());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(vertex.getLabel().toString(),label);
      }
      vertex.setLabel(new StringBuffer(label));
    }
  }
  return currentLabel;
}
Program: 51005
Project: 51005
Buggy source:
private void computeKernelMatrix(List<? extends DirectedGraph<Vertex<String>,Edge<String>>> trainGraphs,List<? extends DirectedGraph<Vertex<String>,Edge<String>>> testGraphs,SparseVector[] featureVectors,double[][] kernel,double[] ss,int iteration){
  for (int i=0; i < testGraphs.size(); i++) {
    for (int j=0; j < trainGraphs.size(); j++) {
      kernel[i][j]+=featureVectors[i].dot(featureVectors[j + testGraphs.size()]) * (((double)iteration) / ((double)this.iterations + 1));
    }
  }
  for (int i=0; i < testGraphs.size() + trainGraphs.size(); i++) {
    ss[i]+=featureVectors[i].dot(featureVectors[i]) * (((double)iteration) / ((double)this.iterations + 1));
  }
}

Fixed version (ground truth):
private void computeKernelMatrix(List<? extends DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> trainGraphs,List<? extends DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> testGraphs,SparseVector[] featureVectors,double[][] kernel,double[] ss){
  for (int i=0; i < testGraphs.size(); i++) {
    for (int j=0; j < trainGraphs.size(); j++) {
      kernel[i][j]+=featureVectors[i].dot(featureVectors[j + testGraphs.size()]);
    }
  }
  for (int i=0; i < testGraphs.size() + trainGraphs.size(); i++) {
    ss[i]+=featureVectors[i].dot(featureVectors[i]);
  }
}
Program: 51006
Project: 51006
Buggy source:
private List<DirectedGraph<Vertex<String>,Edge<String>>> copyGraphs(List<? extends DirectedGraph<Vertex<String>,Edge<String>>> oldGraphs){
  List<DirectedGraph<Vertex<String>,Edge<String>>> graphs=new ArrayList<DirectedGraph<Vertex<String>,Edge<String>>>();
  for (  DirectedGraph<Vertex<String>,Edge<String>> graph : oldGraphs) {
    graphs.add(GraphFactory.copyDirectedGraph(graph));
  }
  return graphs;
}

Fixed version (ground truth):
private List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> copyGraphs(List<DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> oldGraphs){
  List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs=new ArrayList<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>>();
  for (  DirectedMultigraphWithRoot<Vertex<String>,Edge<String>> graph : oldGraphs) {
    DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>> newGraph=new DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>();
    String rootLabel=graph.getRootVertex().getLabel();
    Map<Vertex<String>,Vertex<StringBuffer>> nodes=new HashMap<Vertex<String>,Vertex<StringBuffer>>();
    for (    Vertex<String> vertex : graph.getVertices()) {
      Vertex<StringBuffer> newV=new Vertex<StringBuffer>(new StringBuffer(vertex.getLabel()));
      nodes.put(vertex,newV);
      if (vertex.getLabel().equals(rootLabel)) {
        newGraph.setRootVertex(newV);
      }
    }
    for (    Edge<String> edge : graph.getEdges()) {
      newGraph.addEdge(new Edge<StringBuffer>(new StringBuffer(edge.getLabel())),nodes.get(graph.getSource(edge)),nodes.get(graph.getDest(edge)),EdgeType.DIRECTED);
    }
    graphs.add(newGraph);
  }
  return graphs;
}
Program: 51010
Project: 51010
Buggy source:
/** 
 * @param args
 */
public static void main(String[] args){
  long[] seeds={11,31,51,71,91};
  double[] cs={1,10,100,1000,10000};
  int[] depths={1,2,3};
  int[] iterations={0,2,4,6};
  dataset=new RDFFileDataSet("String_Node_Str",RDFFormat.NTRIPLES);
  createGeoDataSet(10,0.1,"String_Node_Str");
  List<Double> target=EvaluationUtils.createTarget(labels);
  List<EvaluationFunction> evalFuncs=new ArrayList<EvaluationFunction>();
  evalFuncs.add(new Accuracy());
  evalFuncs.add(new F1());
  ResultsTable resTable=new ResultsTable();
  resTable.setManWU(0.05);
  boolean inference=false;
  for (  int i : depths) {
    for (    int it : iterations) {
      resTable.newRow("String_Node_Str");
      LibLINEARParameters linParms=new LibLINEARParameters(LibLINEARParameters.SVC_DUAL,cs);
      KernelExperiment<RDFFeatureVectorKernel> exp=new RDFLinearKernelExperiment(new RDFWLSubTreeKernel(it,i,inference,true),seeds,linParms,dataset,instances,target,blackList,evalFuncs);
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ it);
      exp.run();
      for (      Result res : exp.getResults()) {
        resTable.addResult(res);
      }
    }
  }
  saveResults(resTable,"String_Node_Str");
  resTable.addCompResults(resTable.getBestResults());
  System.out.println(resTable);
  saveResults(resTable.toString(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param args
 */
public static void main(String[] args){
  long[] seeds={11,31,51,71,91};
  double[] cs={1,10,100,1000,10000};
  int[] depths={1,2,3};
  int[] iterations={0,2,4,6};
  dataset=new RDFFileDataSet("String_Node_Str",RDFFormat.NTRIPLES);
  createGeoDataSet(10,0.1,1,"String_Node_Str");
  List<Double> target=EvaluationUtils.createTarget(labels);
  List<EvaluationFunction> evalFuncs=new ArrayList<EvaluationFunction>();
  evalFuncs.add(new Accuracy());
  evalFuncs.add(new F1());
  ResultsTable resTable=new ResultsTable();
  resTable.setManWU(0.05);
  boolean inference=false;
  for (  int i : depths) {
    for (    int it : iterations) {
      resTable.newRow("String_Node_Str");
      LibLINEARParameters linParms=new LibLINEARParameters(LibLINEARParameters.SVC_DUAL,cs);
      KernelExperiment<RDFFeatureVectorKernel> exp=new RDFLinearKernelExperiment(new RDFWLSubTreeKernel(it,i,inference,true),seeds,linParms,dataset,instances,target,blackList,evalFuncs);
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ it);
      exp.run();
      for (      Result res : exp.getResults()) {
        resTable.addResult(res);
      }
    }
  }
  saveResults(resTable,"String_Node_Str");
  resTable.addCompResults(resTable.getBestResults());
  System.out.println(resTable);
  saveResults(resTable.toString(),"String_Node_Str");
}
Program: 51011
Project: 51011
Buggy source:
private static void createGeoDataSet(int minSize,double frac,String property){
  List<Statement> stmts=dataset.getStatementsFromStrings(null,"String_Node_Str","String_Node_Str");
  instances=new ArrayList<Resource>();
  labels=new ArrayList<Value>();
  blackList=new ArrayList<Statement>();
  for (  Statement stmt : stmts) {
    List<Statement> stmts2=dataset.getStatementsFromStrings(stmt.getSubject().toString(),property,null);
    if (stmts2.size() > 1) {
      System.out.println("String_Node_Str");
    }
    for (    Statement stmt2 : stmts2) {
      if (Math.random() < frac) {
        instances.add(stmt2.getSubject());
        labels.add(stmt2.getObject());
      }
    }
  }
  removeSmallClasses(minSize);
  createBlackList();
  Map<Value,Integer> labelMap=new HashMap<Value,Integer>();
  System.out.println(LibSVM.computeClassCounts(LibSVM.createTargets(labels,labelMap)));
}

Fixed version (ground truth):
protected static void createGeoDataSet(int minSize,double frac,long seed,String property){
  List<Statement> stmts=dataset.getStatementsFromStrings(null,"String_Node_Str","String_Node_Str");
  instances=new ArrayList<Resource>();
  labels=new ArrayList<Value>();
  blackList=new ArrayList<Statement>();
  Random rand=new Random(seed);
  for (  Statement stmt : stmts) {
    List<Statement> stmts2=dataset.getStatementsFromStrings(stmt.getSubject().toString(),property,null);
    if (stmts2.size() > 1) {
      System.out.println("String_Node_Str");
    }
    for (    Statement stmt2 : stmts2) {
      if (rand.nextDouble() < frac) {
        instances.add(stmt2.getSubject());
        labels.add(stmt2.getObject());
      }
    }
  }
  removeSmallClasses(minSize);
  createBlackList();
  Map<Value,Integer> labelMap=new HashMap<Value,Integer>();
  System.out.println(LibSVM.computeClassCounts(LibSVM.createTargets(labels,labelMap)));
}
Program: 51013
Project: 51013
Buggy source:
private void compressGraphLabels(DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph){
  String label;
  for (  Edge<Map<Integer,StringBuilder>> edge : graph.getEdges()) {
    for (    int i : edge.getLabel().keySet()) {
      label=labelMap.get(edge.getLabel().get(i));
      if (label == null) {
        label=Integer.toString(labelCounter);
        labelCounter++;
        labelMap.put(edge.getLabel().get(i).toString(),label);
      }
      edge.getLabel().put(i,new StringBuilder(label));
    }
  }
  for (  Vertex<Map<Integer,StringBuilder>> vertex : graph.getVertices()) {
    for (    int i : vertex.getLabel().keySet()) {
      label=labelMap.get(vertex.getLabel().get(i));
      if (label == null) {
        label=Integer.toString(labelCounter);
        labelCounter++;
        labelMap.put(vertex.getLabel().get(i).toString(),label);
      }
      vertex.getLabel().put(i,new StringBuilder(label));
    }
  }
}

Fixed version (ground truth):
private void compressGraphLabels(DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph){
  String label;
  for (  Edge<Map<Integer,StringBuilder>> edge : graph.getEdges()) {
    for (    int i : edge.getLabel().keySet()) {
      label=labelMap.get(edge.getLabel().get(i).toString());
      if (label == null) {
        label=Integer.toString(labelCounter);
        labelCounter++;
        labelMap.put(edge.getLabel().get(i).toString(),label);
      }
      edge.getLabel().put(i,new StringBuilder(label));
    }
  }
  for (  Vertex<Map<Integer,StringBuilder>> vertex : graph.getVertices()) {
    for (    int i : vertex.getLabel().keySet()) {
      label=labelMap.get(vertex.getLabel().get(i).toString());
      if (label == null) {
        label=Integer.toString(labelCounter);
        labelCounter++;
        labelMap.put(vertex.getLabel().get(i).toString(),label);
      }
      vertex.getLabel().put(i,new StringBuilder(label));
    }
  }
}
Program: 51014
Project: 51014
Buggy source:
/** 
 * Second step in the WL algorithm. We compress the long labels into new short labels
 * @param graphs
 * @param labelDict
 * @param currentLabel
 * @return
 */
private int compressGraphLabels(List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs,Map<String,String> labelDict,int currentLabel){
  String label;
  for (  DirectedGraph<Vertex<StringBuffer>,Edge<StringBuffer>> graph : graphs) {
    for (    Edge<StringBuffer> edge : graph.getEdges()) {
      label=labelDict.get(edge.getLabel());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(edge.getLabel().toString(),label);
      }
      edge.setLabel(new StringBuffer(label));
    }
    for (    Vertex<StringBuffer> vertex : graph.getVertices()) {
      label=labelDict.get(vertex.getLabel());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(vertex.getLabel().toString(),label);
      }
      vertex.setLabel(new StringBuffer(label));
    }
  }
  return currentLabel;
}

Fixed version (ground truth):
/** 
 * Second step in the WL algorithm. We compress the long labels into new short labels
 * @param graphs
 * @param labelDict
 * @param currentLabel
 * @return
 */
private int compressGraphLabels(List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs,Map<String,String> labelDict,int currentLabel){
  String label;
  for (  DirectedGraph<Vertex<StringBuffer>,Edge<StringBuffer>> graph : graphs) {
    for (    Edge<StringBuffer> edge : graph.getEdges()) {
      label=labelDict.get(edge.getLabel().toString());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(edge.getLabel().toString(),label);
      }
      edge.setLabel(new StringBuffer(label));
    }
    for (    Vertex<StringBuffer> vertex : graph.getVertices()) {
      label=labelDict.get(vertex.getLabel().toString());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(vertex.getLabel().toString(),label);
      }
      vertex.setLabel(new StringBuffer(label));
    }
  }
  return currentLabel;
}
Program: 51015
Project: 51015
Buggy source:
/** 
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different depth labels.
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph,List<Resource> instances,double weight,SparseVector[] featureVectors){
  int index;
  Map<Vertex<Map<Integer,StringBuilder>>,Integer> vertexIndexMap;
  Map<Edge<Map<Integer,StringBuilder>>,Integer> edgeIndexMap;
  for (int i=0; i < instances.size(); i++) {
    vertexIndexMap=instanceVertexIndexMap.get(instances.get(i).toString());
    for (    Vertex<Map<Integer,StringBuilder>> vertex : vertexIndexMap.keySet()) {
      index=Integer.parseInt(vertex.getLabel().get(vertexIndexMap.get(vertex)).toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
    edgeIndexMap=instanceEdgeIndexMap.get(instances.get(i).toString());
    for (    Edge<Map<Integer,StringBuilder>> edge : edgeIndexMap.keySet()) {
      index=Integer.parseInt(edge.getLabel().get(edgeIndexMap.get(edge)).toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
  }
}

Fixed version (ground truth):
/** 
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different depth labels.
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph,List<Resource> instances,double weight,SparseVector[] featureVectors){
  int index;
  Map<Vertex<Map<Integer,StringBuilder>>,Integer> vertexIndexMap;
  Map<Edge<Map<Integer,StringBuilder>>,Integer> edgeIndexMap;
  for (int i=0; i < instances.size(); i++) {
    featureVectors[i].setLastIndex(labelCounter - 1);
    vertexIndexMap=instanceVertexIndexMap.get(instances.get(i).toString());
    for (    Vertex<Map<Integer,StringBuilder>> vertex : vertexIndexMap.keySet()) {
      index=Integer.parseInt(vertex.getLabel().get(vertexIndexMap.get(vertex)).toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
    edgeIndexMap=instanceEdgeIndexMap.get(instances.get(i).toString());
    for (    Edge<Map<Integer,StringBuilder>> edge : edgeIndexMap.keySet()) {
      index=Integer.parseInt(edge.getLabel().get(edgeIndexMap.get(edge)).toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
  }
}
Program: 51017
Project: 51017
Buggy source:
/** 
 * Second step in the WL algorithm. We compress the long labels into new short labels
 * @param graphs
 * @param labelDict
 * @param currentLabel
 * @return
 */
private int compressGraphLabels(List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs,Map<String,String> labelDict,int currentLabel){
  String label;
  for (  DirectedGraph<Vertex<StringBuffer>,Edge<StringBuffer>> graph : graphs) {
    for (    Edge<StringBuffer> edge : graph.getEdges()) {
      label=labelDict.get(edge.getLabel().toString());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(edge.getLabel().toString(),label);
      }
      edge.setLabel(new StringBuffer(label));
    }
    for (    Vertex<StringBuffer> vertex : graph.getVertices()) {
      label=labelDict.get(vertex.getLabel().toString());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(vertex.getLabel().toString(),label);
      }
      vertex.setLabel(new StringBuffer(label));
    }
  }
  return currentLabel;
}

Fixed version (ground truth):
/** 
 * Second step in the WL algorithm. We compress the long labels into new short labels
 * @param graphs
 * @param labelDict
 * @param currentLabel
 * @return
 */
private int compressGraphLabels(List<DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>>> graphs,Map<String,String> labelDict,int currentLabel){
  String label;
  for (  DirectedGraph<Vertex<StringBuilder>,Edge<StringBuilder>> graph : graphs) {
    for (    Edge<StringBuilder> edge : graph.getEdges()) {
      label=labelDict.get(edge.getLabel().toString());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(edge.getLabel().toString(),label);
      }
      edge.setLabel(new StringBuilder(label));
    }
    for (    Vertex<StringBuilder> vertex : graph.getVertices()) {
      label=labelDict.get(vertex.getLabel().toString());
      if (label == null) {
        label=Integer.toString(currentLabel);
        currentLabel++;
        labelDict.put(vertex.getLabel().toString(),label);
      }
      vertex.setLabel(new StringBuilder(label));
    }
  }
  return currentLabel;
}
Program: 51018
Project: 51018
Buggy source:
/** 
 * Compute feature vector for the graphs based on the label dictionary created in the previous two steps
 * @param graphs
 * @param featureVectors
 * @param startLabel
 * @param currentLabel
 */
private void computeFVs(List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs,SparseVector[] featureVectors,double weight){
  int index;
  for (int i=0; i < graphs.size(); i++) {
    for (    Vertex<StringBuffer> vertex : graphs.get(i).getVertices()) {
      index=Integer.parseInt(vertex.getLabel().toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
    for (    Edge<StringBuffer> edge : graphs.get(i).getEdges()) {
      index=Integer.parseInt(edge.getLabel().toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
  }
}

Fixed version (ground truth):
/** 
 * Compute feature vector for the graphs based on the label dictionary created in the previous two steps
 * @param graphs
 * @param featureVectors
 * @param startLabel
 * @param currentLabel
 */
private void computeFVs(List<DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>>> graphs,SparseVector[] featureVectors,double weight,int lastIndex){
  int index;
  for (int i=0; i < graphs.size(); i++) {
    featureVectors[i].setLastIndex(lastIndex);
    for (    Vertex<StringBuilder> vertex : graphs.get(i).getVertices()) {
      index=Integer.parseInt(vertex.getLabel().toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
    for (    Edge<StringBuilder> edge : graphs.get(i).getEdges()) {
      index=Integer.parseInt(edge.getLabel().toString());
      featureVectors[i].setValue(index,featureVectors[i].getValue(index) + weight);
    }
  }
}
Program: 51019
Project: 51019
Buggy source:
private List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> copyGraphs(List<DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> oldGraphs){
  List<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>> graphs=new ArrayList<DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>>();
  for (  DirectedMultigraphWithRoot<Vertex<String>,Edge<String>> graph : oldGraphs) {
    DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>> newGraph=new DirectedMultigraphWithRoot<Vertex<StringBuffer>,Edge<StringBuffer>>();
    String rootLabel=graph.getRootVertex().getLabel();
    Map<Vertex<String>,Vertex<StringBuffer>> nodes=new HashMap<Vertex<String>,Vertex<StringBuffer>>();
    for (    Vertex<String> vertex : graph.getVertices()) {
      Vertex<StringBuffer> newV=new Vertex<StringBuffer>(new StringBuffer(vertex.getLabel()));
      nodes.put(vertex,newV);
      if (vertex.getLabel().equals(rootLabel)) {
        newGraph.setRootVertex(newV);
      }
    }
    for (    Edge<String> edge : graph.getEdges()) {
      newGraph.addEdge(new Edge<StringBuffer>(new StringBuffer(edge.getLabel())),nodes.get(graph.getSource(edge)),nodes.get(graph.getDest(edge)),EdgeType.DIRECTED);
    }
    graphs.add(newGraph);
  }
  return graphs;
}

Fixed version (ground truth):
private List<DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>>> copyGraphs(List<DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> oldGraphs){
  List<DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>>> graphs=new ArrayList<DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>>>();
  for (  DirectedMultigraphWithRoot<Vertex<String>,Edge<String>> graph : oldGraphs) {
    DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>> newGraph=new DirectedMultigraphWithRoot<Vertex<StringBuilder>,Edge<StringBuilder>>();
    String rootLabel=graph.getRootVertex().getLabel();
    Map<Vertex<String>,Vertex<StringBuilder>> nodes=new HashMap<Vertex<String>,Vertex<StringBuilder>>();
    for (    Vertex<String> vertex : graph.getVertices()) {
      Vertex<StringBuilder> newV=new Vertex<StringBuilder>(new StringBuilder(vertex.getLabel()));
      nodes.put(vertex,newV);
      if (vertex.getLabel().equals(rootLabel)) {
        newGraph.setRootVertex(newV);
      }
    }
    for (    Edge<String> edge : graph.getEdges()) {
      newGraph.addEdge(new Edge<StringBuilder>(new StringBuilder(edge.getLabel())),nodes.get(graph.getSource(edge)),nodes.get(graph.getDest(edge)),EdgeType.DIRECTED);
    }
    graphs.add(newGraph);
  }
  return graphs;
}
Program: 51021
Project: 51021
Buggy source:
/** 
 * @param args
 */
public static void main(String[] args){
  long[] seeds={11,21,31,41,51,61,71,81,91,101};
  double[] cs={0.001,0.01,0.1,1,10,100,1000};
  int depth=3;
  int[] iterations={0,2,4,6};
  dataset=new RDFFileDataSet("String_Node_Str",RDFFormat.NTRIPLES);
  createGeoDataSet(50,"String_Node_Str");
  ResultsTable resTable=new ResultsTable();
  resTable.setManWU(0.05);
  boolean inference=false;
  for (int i=1; i <= depth; i++) {
    resTable.newRow("String_Node_Str");
    for (    int it : iterations) {
      LibSVMParameters parms=new LibSVMParameters(LibSVMParameters.C_SVC,cs);
      LibLINEARParameters linParms=new LibLINEARParameters(LibLINEARParameters.SVC_DUAL,cs);
      KernelExperiment<RDFWLSubTreeKernel> exp=new RDFLinearVSKernelExperiment(new RDFWLSubTreeKernel(it,i,inference,true),seeds,parms,linParms,dataset,instances,labels,blackList);
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ it);
      exp.run();
      for (      Result res : exp.getResults()) {
        resTable.addResult(res);
      }
    }
  }
  saveResults(resTable,"String_Node_Str");
  resTable.addCompResults(resTable.getBestResults());
  System.out.println(resTable);
  saveResults(resTable.toString(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param args
 */
public static void main(String[] args){
  long[] seeds={11,21,31,41,51,61,71,81,91,101};
  double[] cs={1,10,100,1000};
  int depth=3;
  int[] iterations={0,2,4,6};
  dataset=new RDFFileDataSet("String_Node_Str",RDFFormat.NTRIPLES);
  createGeoDataSet(10,"String_Node_Str");
  ResultsTable resTable=new ResultsTable();
  resTable.setManWU(0.05);
  boolean inference=false;
  for (int i=1; i <= depth; i++) {
    for (    int it : iterations) {
      resTable.newRow("String_Node_Str");
      LibSVMParameters parms=new LibSVMParameters(LibSVMParameters.C_SVC,cs);
      LibLINEARParameters linParms=new LibLINEARParameters(LibLINEARParameters.SVC_DUAL,cs);
      KernelExperiment<RDFWLSubTreeKernel> exp=new RDFLinearVSKernelExperiment(new RDFWLSubTreeKernel(it,i,inference,true),seeds,parms,linParms,dataset,instances,labels,blackList);
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ it);
      exp.run();
      for (      Result res : exp.getResults()) {
        resTable.addResult(res);
      }
    }
  }
  saveResults(resTable,"String_Node_Str");
  resTable.addCompResults(resTable.getBestResults());
  System.out.println(resTable);
  saveResults(resTable.toString(),"String_Node_Str");
}
Program: 51022
Project: 51022
Buggy source:
private static void createGeoDataSet(int minSize,String property){
  List<Statement> stmts=dataset.getStatementsFromStrings(null,"String_Node_Str","String_Node_Str");
  instances=new ArrayList<Resource>();
  labels=new ArrayList<Value>();
  blackList=new ArrayList<Statement>();
  for (  Statement stmt : stmts) {
    List<Statement> stmts2=dataset.getStatementsFromStrings(stmt.getSubject().toString(),property,null);
    if (stmts2.size() > 1) {
      System.out.println("String_Node_Str");
    }
    for (    Statement stmt2 : stmts2) {
      if (Math.random() < 0.1) {
        instances.add(stmt2.getSubject());
        labels.add(stmt2.getObject());
      }
    }
  }
  removeSmallClasses(minSize);
  createBlackList();
  Map<Value,Integer> labelMap=new HashMap<Value,Integer>();
  System.out.println(LibSVM.computeClassCounts(LibSVM.createTargets(labels,labelMap)));
}

Fixed version (ground truth):
private static void createGeoDataSet(int minSize,String property){
  List<Statement> stmts=dataset.getStatementsFromStrings(null,"String_Node_Str","String_Node_Str");
  instances=new ArrayList<Resource>();
  labels=new ArrayList<Value>();
  blackList=new ArrayList<Statement>();
  for (  Statement stmt : stmts) {
    List<Statement> stmts2=dataset.getStatementsFromStrings(stmt.getSubject().toString(),property,null);
    if (stmts2.size() > 1) {
      System.out.println("String_Node_Str");
    }
    for (    Statement stmt2 : stmts2) {
      if (Math.random() < 0.01) {
        instances.add(stmt2.getSubject());
        labels.add(stmt2.getObject());
      }
    }
  }
  removeSmallClasses(minSize);
  createBlackList();
  Map<Value,Integer> labelMap=new HashMap<Value,Integer>();
  System.out.println(LibSVM.computeClassCounts(LibSVM.createTargets(labels,labelMap)));
}
Program: 51025
Project: 51025
Buggy source:
public static double[][] featureVectors2Kernel(SparseVector[] featureVectors,boolean normalize){
  double[][] kernel=initMatrix(featureVectors.length,featureVectors.length);
  for (int i=0; i < featureVectors.length; i++) {
    for (int j=i; j < featureVectors.length; j++) {
      kernel[i][j]=featureVectors[i].dot(featureVectors[j]);
      kernel[j][i]=kernel[i][j];
    }
  }
  if (normalize) {
    kernel=normalize(kernel);
  }
  return kernel;
}

Fixed version (ground truth):
public static double[][] featureVectors2Kernel(SparseVector[] featureVectors){
  double[][] kernel=initMatrix(featureVectors.length,featureVectors.length);
  for (int i=0; i < featureVectors.length; i++) {
    for (int j=i; j < featureVectors.length; j++) {
      kernel[i][j]=featureVectors[i].dot(featureVectors[j]);
      kernel[j][i]=kernel[i][j];
    }
  }
  return kernel;
}
Program: 51026
Project: 51026
Buggy source:
public double[][] compute(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=computeFeatureVectors(dataset,instances,blackList);
  double[][] kernel=initMatrix(instances.size(),instances.size());
  computeKernelMatrix(instances,featureVectors,kernel,1);
  if (this.normalize) {
    kernel=normalize(kernel);
  }
  return kernel;
}

Fixed version (ground truth):
public double[][] compute(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=computeFeatureVectors(dataset,instances,blackList);
  double[][] kernel=initMatrix(instances.size(),instances.size());
  computeKernelMatrix(instances,featureVectors,kernel,1);
  return kernel;
}
Program: 51027
Project: 51027
Buggy source:
public double dot(SparseVector v2){
  int i=0, j=0;
  double ret=0;
  if (!converted) {
    convert2Arrays();
  }
  if (!v2.converted) {
    v2.convert2Arrays();
  }
  while (i < indices.length && j < v2.indices.length) {
    if (indices[i] == v2.indices[j]) {
      ret+=values[i] * v2.values[j];
      i++;
      j++;
    }
 else     if (indices[i] < v2.indices[j]) {
      j++;
    }
 else {
      i++;
    }
  }
  return ret;
}

Fixed version (ground truth):
public double dot(SparseVector v2){
  int i=0, j=0;
  double ret=0;
  if (!converted) {
    convert2Arrays();
  }
  if (!v2.converted) {
    v2.convert2Arrays();
  }
  while (i < indices.length && j < v2.indices.length) {
    if (indices[i] > v2.indices[j]) {
      j++;
    }
 else     if (indices[i] < v2.indices[j]) {
      i++;
    }
 else {
      ret+=values[i] * v2.values[j];
      i++;
      j++;
    }
  }
  return ret;
}
Program: 51028
Project: 51028
Buggy source:
/** 
 * @param args
 */
public static void main(String[] args){
  long[] seeds={11,21,31,41,51,61,71,81,91,101};
  double[] cs={1,10,100,1000};
  int depth=3;
  int[] iterations={0,2,4,6};
  dataset=new RDFFileDataSet("String_Node_Str",RDFFormat.NTRIPLES);
  createGeoDataSet(10,"String_Node_Str");
  ResultsTable resTable=new ResultsTable();
  resTable.setManWU(0.05);
  boolean inference=false;
  for (int i=1; i <= depth; i++) {
    for (    int it : iterations) {
      resTable.newRow("String_Node_Str");
      LibSVMParameters parms=new LibSVMParameters(LibSVMParameters.C_SVC,cs);
      LibLINEARParameters linParms=new LibLINEARParameters(LibLINEARParameters.SVC_DUAL,cs);
      KernelExperiment<RDFWLSubTreeKernel> exp=new RDFLinearVSKernelExperiment(new RDFWLSubTreeKernel(it,i,inference,true),seeds,parms,linParms,dataset,instances,labels,blackList);
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ it);
      exp.run();
      for (      Result res : exp.getResults()) {
        resTable.addResult(res);
      }
    }
  }
  saveResults(resTable,"String_Node_Str");
  resTable.addCompResults(resTable.getBestResults());
  System.out.println(resTable);
  saveResults(resTable.toString(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param args
 */
public static void main(String[] args){
  long[] seeds={11,21,31,41,51,61,71,81,91,101};
  double[] cs={1,10,100,1000};
  int depth=3;
  int[] iterations={0,2,4};
  dataset=new RDFFileDataSet("String_Node_Str",RDFFormat.NTRIPLES);
  createGeoDataSet(10,"String_Node_Str");
  ResultsTable resTable=new ResultsTable();
  resTable.setManWU(0.05);
  boolean inference=false;
  for (int i=1; i <= depth; i++) {
    for (    int it : iterations) {
      resTable.newRow("String_Node_Str");
      LibSVMParameters parms=new LibSVMParameters(LibSVMParameters.C_SVC,cs);
      LibLINEARParameters linParms=new LibLINEARParameters(LibLINEARParameters.SVC_DUAL,cs);
      KernelExperiment<RDFWLSubTreeKernel> exp=new RDFLinearVSKernelExperiment(new RDFWLSubTreeKernel(it,i,inference,true),seeds,parms,linParms,dataset,instances,labels,blackList);
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ it);
      exp.run();
      for (      Result res : exp.getResults()) {
        resTable.addResult(res);
      }
    }
  }
  saveResults(resTable,"String_Node_Str");
  resTable.addCompResults(resTable.getBestResults());
  System.out.println(resTable);
  saveResults(resTable.toString(),"String_Node_Str");
}
Program: 51030
Project: 51030
Buggy source:
public SparseVector[] computeFeatureVectors(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=new SparseVector[instances.size()];
  for (int i=0; i < featureVectors.length; i++) {
    featureVectors[i]=new SparseVector();
  }
  int startLabel=1;
  DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph=createGraphFromRDF(dataset,instances,blackList);
  createInstanceIndexMaps(graph,instances);
  if (blankLabels) {
    setBlankLabels(graph);
  }
  computeFVs(graph,instances,1,featureVectors);
  for (int i=0; i < iterations; i++) {
    relabelGraph2MultisetLabels(graph,startLabel);
    startLabel=labelCounter;
    compressGraphLabels(graph);
    computeFVs(graph,instances,1,featureVectors);
  }
  if (this.normalize) {
    featureVectors=Kernel.normalize(featureVectors);
  }
  return featureVectors;
}

Fixed version (ground truth):
public SparseVector[] computeFeatureVectors(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=new SparseVector[instances.size()];
  for (int i=0; i < featureVectors.length; i++) {
    featureVectors[i]=new SparseVector();
  }
  int startLabel=1;
  DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph=createGraphFromRDF(dataset,instances,blackList);
  createInstanceIndexMaps(graph,instances);
  if (blankLabels) {
    setBlankLabels(graph);
  }
  computeFVs(graph,instances,1.0 / Math.sqrt(iterations + 1),featureVectors);
  for (int i=0; i < iterations; i++) {
    relabelGraph2MultisetLabels(graph,startLabel);
    startLabel=labelCounter;
    compressGraphLabels(graph);
    computeFVs(graph,instances,(2.0 + i) / Math.sqrt(iterations + 1),featureVectors);
  }
  if (this.normalize) {
    featureVectors=Kernel.normalize(featureVectors);
  }
  return featureVectors;
}
Program: 51031
Project: 51031
Buggy source:
public double[][] compute(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=computeFeatureVectors(dataset,instances,blackList);
  double[][] kernel=initMatrix(instances.size(),instances.size());
  computeKernelMatrix(instances,featureVectors,kernel,1);
  return kernel;
}

Fixed version (ground truth):
public double[][] compute(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=computeFeatureVectors(dataset,instances,blackList);
  double[][] kernel=initMatrix(instances.size(),instances.size());
  computeKernelMatrix(instances,featureVectors,kernel);
  return kernel;
}
Program: 51032
Project: 51032
Buggy source:
public SparseVector[] computeFeatureVectors(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=new SparseVector[instances.size()];
  for (int i=0; i < featureVectors.length; i++) {
    featureVectors[i]=new SparseVector();
  }
  int startLabel=1;
  DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph=createGraphFromRDF(dataset,instances,blackList);
  createInstanceIndexMaps(graph,instances);
  if (blankLabels) {
    setBlankLabels(graph);
  }
  computeFVs(graph,instances,1.0 / Math.sqrt(iterations + 1),featureVectors);
  for (int i=0; i < iterations; i++) {
    relabelGraph2MultisetLabels(graph,startLabel);
    startLabel=labelCounter;
    compressGraphLabels(graph);
    computeFVs(graph,instances,(2.0 + i) / Math.sqrt(iterations + 1),featureVectors);
  }
  if (this.normalize) {
    featureVectors=Kernel.normalize(featureVectors);
  }
  return featureVectors;
}

Fixed version (ground truth):
public SparseVector[] computeFeatureVectors(RDFDataSet dataset,List<Resource> instances,List<Statement> blackList){
  SparseVector[] featureVectors=new SparseVector[instances.size()];
  for (int i=0; i < featureVectors.length; i++) {
    featureVectors[i]=new SparseVector();
  }
  DirectedGraph<Vertex<Map<Integer,StringBuilder>>,Edge<Map<Integer,StringBuilder>>> graph=createGraphFromRDF(dataset,instances,blackList);
  createInstanceIndexMaps(graph,instances);
  if (blankLabels) {
    setBlankLabels(graph);
  }
  computeFVs(graph,instances,Math.sqrt(1.0 / ((double)(iterations + 1))),featureVectors);
  int startLabel=1;
  for (int i=0; i < iterations; i++) {
    relabelGraph2MultisetLabels(graph,startLabel);
    startLabel=labelCounter;
    compressGraphLabels(graph);
    computeFVs(graph,instances,Math.sqrt((2.0 + i) / ((double)(iterations + 1))),featureVectors);
  }
  if (this.normalize) {
    featureVectors=Kernel.normalize(featureVectors);
  }
  return featureVectors;
}
Program: 51033
Project: 51033
Buggy source:
/** 
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different depth labels.
 * @param graph
 * @param instances
 * @param startLabel
 * @param featureVectors
 */
private void computeKernelMatrix(List<Resource> instances,SparseVector[] featureVectors,double[][] kernel,int iteration){
  for (int i=0; i < instances.size(); i++) {
    for (int j=i; j < instances.size(); j++) {
      kernel[i][j]+=featureVectors[i].dot(featureVectors[j]) * ((iteration) / ((double)this.iterations + 1));
      kernel[j][i]=kernel[i][j];
    }
  }
}

Fixed version (ground truth):
/** 
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different depth labels.
 * @param graph
 * @param instances
 * @param startLabel
 * @param featureVectors
 */
private void computeKernelMatrix(List<Resource> instances,SparseVector[] featureVectors,double[][] kernel){
  for (int i=0; i < instances.size(); i++) {
    for (int j=i; j < instances.size(); j++) {
      kernel[i][j]+=featureVectors[i].dot(featureVectors[j]);
      kernel[j][i]=kernel[i][j];
    }
  }
}
Program: 51034
Project: 51034
Buggy source:
private static LibSVMModel trainSVMModel(svm_problem svmProb,double[] target,LibSVMParameters params){
  if (!params.isVerbose()) {
    setNoOutput();
  }
  double[] prediction=new double[target.length];
  svm_parameter svmParams=params.getParams();
  double score=0, bestScore=0, bestC=1;
  for (  double c : params.getItParams()) {
    if (svmParams.svm_type == LibSVMParameters.C_SVC || svmParams.svm_type == LibSVMParameters.EPSILON_SVR) {
      svmParams.C=c;
    }
 else {
      svmParams.nu=c;
    }
    svm.svm_cross_validation(svmProb,svmParams,10,prediction);
    if (params.getEvalFunction() == LibSVM.ACCURACY) {
      score=computeAccuracy(target,prediction);
    }
    if (params.getEvalFunction() == LibSVM.F1) {
      score=computeF1(target,prediction);
    }
    if (params.getEvalFunction() == LibSVM.MSE) {
      score=1 / computeMeanSquaredError(target,prediction);
    }
    if (params.getEvalFunction() == LibSVM.MAE) {
      score=1 / computeMeanAbsoluteError(target,prediction);
    }
    if (score > bestScore) {
      bestC=c;
      bestScore=score;
    }
  }
  svmParams.C=bestC;
  return new LibSVMModel(svm.svm_train(svmProb,svmParams));
}

Fixed version (ground truth):
private static LibSVMModel trainSVMModel(svm_problem svmProb,double[] target,LibSVMParameters params){
  if (!params.isVerbose()) {
    setNoOutput();
  }
  double[] prediction=new double[target.length];
  svm_parameter svmParams=params.getParams();
  double score=0, bestScore=0, bestC=1;
  for (  double c : params.getItParams()) {
    if (svmParams.svm_type == LibSVMParameters.C_SVC || svmParams.svm_type == LibSVMParameters.EPSILON_SVR) {
      svmParams.C=c;
    }
 else {
      svmParams.nu=c;
    }
    svm.svm_cross_validation(svmProb,svmParams,5,prediction);
    if (params.getEvalFunction() == LibSVM.ACCURACY) {
      score=computeAccuracy(target,prediction);
    }
    if (params.getEvalFunction() == LibSVM.F1) {
      score=computeF1(target,prediction);
    }
    if (params.getEvalFunction() == LibSVM.MSE) {
      score=1 / computeMeanSquaredError(target,prediction);
    }
    if (params.getEvalFunction() == LibSVM.MAE) {
      score=1 / computeMeanAbsoluteError(target,prediction);
    }
    if (score > bestScore) {
      bestC=c;
      bestScore=score;
    }
  }
  svmParams.C=bestC;
  return new LibSVMModel(svm.svm_train(svmProb,svmParams));
}
Program: 51035
Project: 51035
Buggy source:
/** 
 * Note that the itParams have to be set manually when using this constructor.
 * @param algorithm, one of the 5 algorithms
 */
public LibSVMParameters(int algorithm){
  params=new svm_parameter();
  params.svm_type=algorithm;
  params.kernel_type=svm_parameter.PRECOMPUTED;
  params.eps=0.0001;
  params.shrinking=0;
  params.probability=0;
  params.cache_size=300;
  params.nr_weight=0;
  params.p=0.1;
  verbose=false;
  if (params.svm_type == EPSILON_SVR || params.svm_type == NU_SVR) {
    evalFunction=LibSVM.MSE;
  }
 else {
    evalFunction=LibSVM.ACCURACY;
  }
}

Fixed version (ground truth):
/** 
 * Note that the itParams have to be set manually when using this constructor.
 * @param algorithm, one of the 5 algorithms
 */
public LibSVMParameters(int algorithm){
  params=new svm_parameter();
  params.svm_type=algorithm;
  params.kernel_type=svm_parameter.PRECOMPUTED;
  params.eps=0.00001;
  params.shrinking=0;
  params.probability=0;
  params.cache_size=300;
  params.nr_weight=0;
  params.p=0.1;
  verbose=false;
  if (params.svm_type == EPSILON_SVR || params.svm_type == NU_SVR) {
    evalFunction=LibSVM.MSE;
  }
 else {
    evalFunction=LibSVM.ACCURACY;
  }
}
Program: 51037
Project: 51037
Buggy source:
@Override public double[][] compute(List<? extends DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> trainGraphs,List<? extends DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> testGraphs){
  double[][] kernel=initMatrix(testGraphs.size(),trainGraphs.size());
  DirectedGraph<Vertex<String>,Edge<String>> graph;
  double[] ssTest=new double[testGraphs.size()];
  double[] ssTrain=new double[trainGraphs.size()];
  for (int i=0; i < testGraphs.size(); i++) {
    for (int j=0; j < trainGraphs.size(); j++) {
      graph=computeIntersectionGraph(testGraphs.get(i),trainGraphs.get(j));
      kernel[i][j]=subGraphCount(graph,maxLength,discountFactor);
    }
  }
  for (int i=0; i < testGraphs.size(); i++) {
    graph=computeIntersectionGraph(testGraphs.get(i),testGraphs.get(i));
    ssTest[i]=subGraphCount(graph,maxLength,discountFactor);
  }
  for (int i=0; i < trainGraphs.size(); i++) {
    graph=computeIntersectionGraph(trainGraphs.get(i),trainGraphs.get(i));
    ssTrain[i]=subGraphCount(graph,maxLength,discountFactor);
  }
  if (normalize) {
    return normalize(kernel,ssTrain,ssTest);
  }
 else {
    return kernel;
  }
}

Fixed version (ground truth):
@Override public double[][] compute(List<? extends DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> trainGraphs,List<? extends DirectedMultigraphWithRoot<Vertex<String>,Edge<String>>> testGraphs){
  double[][] kernel=initMatrix(testGraphs.size(),trainGraphs.size());
  DirectedGraph<Vertex<String>,Edge<String>> graph;
  double[] ssTest=new double[testGraphs.size()];
  double[] ssTrain=new double[trainGraphs.size()];
  for (  DirectedMultigraphWithRoot<Vertex<String>,Edge<String>> graphT : trainGraphs) {
    graphT.getRootVertex().setLabel(ROOTID);
  }
  for (  DirectedMultigraphWithRoot<Vertex<String>,Edge<String>> graphT : testGraphs) {
    graphT.getRootVertex().setLabel(ROOTID);
  }
  for (int i=0; i < testGraphs.size(); i++) {
    for (int j=0; j < trainGraphs.size(); j++) {
      graph=computeIntersectionGraph(testGraphs.get(i),trainGraphs.get(j));
      kernel[i][j]=subGraphCount(graph,maxLength,discountFactor);
    }
  }
  for (int i=0; i < testGraphs.size(); i++) {
    graph=computeIntersectionGraph(testGraphs.get(i),testGraphs.get(i));
    ssTest[i]=subGraphCount(graph,maxLength,discountFactor);
  }
  for (int i=0; i < trainGraphs.size(); i++) {
    graph=computeIntersectionGraph(trainGraphs.get(i),trainGraphs.get(i));
    ssTrain[i]=subGraphCount(graph,maxLength,discountFactor);
  }
  if (normalize) {
    return normalize(kernel,ssTrain,ssTest);
  }
 else {
    return kernel;
  }
}