nus-yam/ex-repair huggingface dataset:
Program: 39709
Project: 39709
Buggy source:
private int drawPANode(int a,int b){
  int sum1=0;
  for (int i=a; i <= b; i++)   sum1+=g.getNode(a).getDegree();
  int zz=rnd.nextInt(sum1);
  int node=a;
  int sum2=g.getNode(a).getDegree();
  while (zz > sum2) {
    node++;
    sum2=sum2 + g.getNode(a).getDegree();
  }
  return node;
}

Fixed version (ground truth):
private int drawPANode(int a,int b){
  int sum1=0;
  for (int i=a; i <= b; i++)   sum1+=g.getNode(i).getDegree();
  int zz=rnd.nextInt(sum1);
  int node=a;
  int sum2=g.getNode(a).getDegree();
  while (zz > sum2) {
    node++;
    sum2=sum2 + g.getNode(node).getDegree();
  }
  return node;
}
Program: 39710
Project: 39710
Buggy source:
@Override public Graph generate(){
  rnd=new Random(System.currentTimeMillis());
  generateCommunitiySizes();
  g=new Graph(this.getDescription());
  nodes=Node.init(this.getNodes(),g);
  edges=new Edges(nodes,m * getNodes() + 2 * z);
  for (int i=0; i < communitySizes.length; i++) {
    int size=communitySizes[i];
    Graph c=new WoTModelSingleCommunity(size,8,0,1,0.52,"String_Node_Str",null).generate();
    for (    Node n : c.getNodes()) {
      int out[]=n.getOutgoingEdges();
      for (      int dst : out)       edges.add(n.getIndex() + firstNode[i],dst + firstNode[i]);
    }
  }
  edges.fill();
  g.setNodes(nodes);
  bridgeNode=new int[communitySizes.length];
  for (int i=0; i < communitySizes.length; i++) {
    bridgeNode[i]=drawPANode(firstNode[i],lastNode[i]);
  }
  int bridge=getNodeWithMaxDegree();
  for (int i=0; i < communitySizes.length; i++) {
    int c=0;
    int a=drawPANode(firstNode[i],lastNode[i]);
    int b=drawPANode(firstNode[c],lastNode[c]);
    edges.add(a,b);
    edges.add(b,a);
  }
  int addedEdges=0;
  while (addedEdges < z * communitySizes.length) {
    int c1=drawPACommunity(-1);
    int c2=drawPACommunity(c1);
    int n1=drawPANode(firstNode[c1],lastNode[c1]);
    int n2=drawPANode(firstNode[c2],lastNode[c2]);
    if (!edges.contains(n1,n2) && !edges.contains(n2,n1)) {
      edges.add(n1,n2);
      edges.add(n2,n1);
      addedEdges++;
    }
  }
  edges.fill();
  g.setNodes(nodes);
  return g;
}

Fixed version (ground truth):
@Override public Graph generate(){
  rnd=new Random(System.currentTimeMillis());
  generateCommunitiySizes();
  g=new Graph(this.getDescription());
  nodes=Node.init(this.getNodes(),g);
  edges=new Edges(nodes,m * getNodes() + 2 * z);
  for (int i=0; i < communitySizes.length; i++) {
    int size=communitySizes[i];
    Graph c=new WoTModelSingleCommunity(size,8,0,1,0.52,"String_Node_Str",null).generate();
    for (    Node n : c.getNodes()) {
      int out[]=n.getOutgoingEdges();
      for (      int dst : out)       edges.add(n.getIndex() + firstNode[i],dst + firstNode[i]);
    }
  }
  edges.fill();
  g.setNodes(nodes);
  for (int i=0; i < communitySizes.length; i++) {
    int c=0;
    int a=drawPANode(firstNode[i],lastNode[i]);
    int b=drawPANode(firstNode[c],lastNode[c]);
    edges.add(a,b);
    edges.add(b,a);
  }
  int addedEdges=0;
  while (addedEdges < z * communitySizes.length) {
    int c1=drawPACommunity(-1);
    int c2=drawPACommunity(c1);
    int n1=drawPANode(firstNode[c1],lastNode[c1]);
    int n2=drawPANode(firstNode[c2],lastNode[c2]);
    if (!edges.contains(n1,n2) && !edges.contains(n2,n1)) {
      edges.add(n1,n2);
      edges.add(n2,n1);
      addedEdges++;
    }
  }
  edges.fill();
  g.setNodes(nodes);
  return g;
}
Program: 39713
Project: 39713
Buggy source:
/** 
 * @param args
 * @throws ParseException
 */
public static void main(String[] args) throws ParseException {
  for (  String s : args) {
    matchArgument(s);
  }
  GraphReader gr=null;
  if (snap) {
    gr=new SnapGraphReader();
  }
 else   if (caida) {
    gr=new CaidaGraphReader();
  }
  File f=new File(path);
  List<File> lof=Arrays.asList(f.listFiles());
  ArrayList<File> alof=new ArrayList<File>();
  ArrayList<String> names=new ArrayList<String>();
  for (  File fi : lof) {
    if (fi.isFile() && !fi.isHidden()) {
      alof.add(fi);
      names.add(fi.getName());
    }
  }
  File[] arlof=alof.toArray(new File[0]);
  String[] gNames=names.toArray(new String[0]);
  for (int i=0; i < arlof.length; i++) {
    Graph g=gr.read(arlof[i].getAbsolutePath());
    writeGraphToFile(g,path + "String_Node_Str" + gNames[i]);
    g=null;
  }
}

Fixed version (ground truth):
/** 
 * @param args
 * @throws ParseException
 * @throws IOException 
 */
public static void main(String[] args) throws ParseException, IOException {
  for (  String s : args) {
    matchArgument(s);
  }
  GraphReader gr=null;
  System.out.print("String_Node_Str");
  if (snap) {
    System.out.println("String_Node_Str");
    gr=new SnapGraphReader();
  }
 else   if (caida) {
    System.out.println("String_Node_Str");
    gr=new CaidaGraphReader();
  }
  System.out.println("String_Node_Str" + gr.hashCode());
  File f=new File(path);
  List<File> lof=Arrays.asList(f.listFiles());
  ArrayList<File> alof=new ArrayList<File>();
  ArrayList<String> names=new ArrayList<String>();
  for (  File fi : lof) {
    if (fi.isFile() && !fi.isHidden()) {
      System.out.println("String_Node_Str" + fi.getAbsolutePath());
      System.out.println("String_Node_Str" + fi.getName());
      alof.add(fi);
      names.add(fi.getName());
    }
  }
  for (int i=0; i < alof.size(); i++) {
    String p=alof.get(i).getAbsolutePath();
    System.out.println("String_Node_Str" + p);
    Graph g=gr.read(p);
    writeGraphToFile(g,path + "String_Node_Str" + names.get(i));
    g=null;
  }
}
Program: 39714
Project: 39714
Buggy source:
public static Network[] instantiateNetworkModels(){
  Network nw1=new ErdosRenyi(100,3,false,null);
  Network nw2=new BarabasiAlbert(500,2,null);
  Network nw3=new WattsStrogatz(500,6,0.2,null);
  Network nw4=new CondonAndKarp(500,3,0.05,0.0005,null);
  Network nw5=new Regular(100,2,true,false,null);
  Network[] n=new Network[]{nw4};
  return n;
}

Fixed version (ground truth):
public static Network[] instantiateNetworkModels(){
  Network nw1=new ErdosRenyi(100,3,false,null);
  Network nw2=new BarabasiAlbert(500,2,null);
  Network nw3=new WattsStrogatz(500,6,0.2,null);
  Network nw4=new CondonAndKarp(500,3,0.05,0.0005,null);
  Network nw5=new Regular(100,2,true,false,null);
  Network[] n=new Network[]{nw1};
  return n;
}
Program: 39716
Project: 39716
Buggy source:
@Override protected Node selectNextNode(Collection<Node> candidates,Node current){
  Random r=new Random();
  int next=r.nextInt(candidates.size());
  next=next % candidates.size();
  Node nextStepCandidate=candidates.toArray(new Node[0])[next];
  int nscDegree=nextStepCandidate.getDegree();
  int cDegree=current.getDegree();
  double d=(double)cDegree / (double)nscDegree;
  d=Math.min(d,1);
  double p=r.nextDouble();
  if (d < p) {
    return nextStepCandidate;
  }
 else {
    return current;
  }
}

Fixed version (ground truth):
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=this.getRNG();
  Collection<Node> c=this.getCurrentNodes();
  if (c.size() > 0) {
    Node current=c.toArray(new Node[0])[0];
    int next=r.nextInt(candidates.size());
    next=next % candidates.size();
    Node nextStepCandidate=candidates.toArray(new Node[0])[next];
    int nscDegree=nextStepCandidate.getDegree();
    int cDegree=current.getDegree();
    double d=(double)cDegree / (double)nscDegree;
    d=Math.min(d,1);
    double p=r.nextDouble();
    if (d < p) {
      return nextStepCandidate;
    }
 else {
      System.err.println("String_Node_Str" + cDegree + "String_Node_Str"+ nscDegree);
      return current;
    }
  }
 else {
    c=this.getRestartNodes();
    return c.toArray(new Node[0])[0];
  }
}
Program: 39717
Project: 39717
Buggy source:
/** 
 * returns the list of neighbors as candidates
 * @param g Graph
 * @param n Current node
 * @return List of candidates
 */
@Override public Collection<Node> resolveCandidates(Graph g,Node n){
  int[] nids=n.getOutgoingEdges();
  ArrayList<Node> nn=new ArrayList<Node>();
  for (  int i : nids) {
    nn.add(g.getNode(i));
  }
  return nn;
}

Fixed version (ground truth):
public Collection<Node> resolveCandidates(Graph g,Node n){
  int[] nids=n.getOutgoingEdges();
  ArrayList<Node> nn=new ArrayList<Node>();
  for (  int i : nids) {
    nn.add(g.getNode(i));
  }
  return nn;
}
Program: 39719
Project: 39719
Buggy source:
/** 
 * @param args
 */
public static void main(String[] args){
  Config.overwrite("String_Node_Str","String_Node_Str");
  boolean get=false;
  int times=1;
  double scaledown=0.5;
  int dimension=1;
  boolean revisiting=false;
  Transformation uniformSampling=SamplingAlgorithmFactory.getInstanceOf(SamplingAlgorithm.UNIFORMSAMPLING,scaledown,revisiting,dimension);
  Transformation[] t=new Transformation[]{uniformSampling};
  Network nw1=new ErdosRenyi(10,3,false,t);
  Network[] n=new Network[]{nw1};
  Metric[] metrics=new Metric[]{new DegreeDistribution(),new ShortestPaths(),new ClusteringCoefficient()};
  Series[] s=get ? Series.get(n,metrics) : Series.generate(n,metrics,times);
  Plotting.single(s,metrics,"String_Node_Str");
  Plotting.multi(s,metrics,"String_Node_Str");
  for (  Network i : n) {
    System.out.println("String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes()+ "String_Node_Str");
    plot(i,"String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes(),times);
  }
}

Fixed version (ground truth):
/** 
 * @param args
 */
public static void main(String[] args){
  Config.overwrite("String_Node_Str","String_Node_Str");
  boolean get=false;
  int times=1;
  double scaledown=0.1;
  int dimension=1;
  boolean revisiting=false;
  Transformation uniformSampling=SamplingAlgorithmFactory.getInstanceOf(SamplingAlgorithm.UNIFORMSAMPLING,scaledown,revisiting,dimension);
  Transformation[] t=new Transformation[]{uniformSampling};
  Network nw1=new ErdosRenyi(10000,12,false,t);
  Network[] n=new Network[]{nw1};
  Metric[] metrics=new Metric[]{new DegreeDistribution(),new ShortestPaths(),new ClusteringCoefficient()};
  Series[] s=get ? Series.get(n,metrics) : Series.generate(n,metrics,times);
  Plotting.single(s,metrics,"String_Node_Str");
  Plotting.multi(s,metrics,"String_Node_Str");
  for (  Network i : n) {
    System.out.println("String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes()+ "String_Node_Str");
    plot(i,"String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes(),times);
  }
}
Program: 39720
Project: 39720
Buggy source:
/** 
 * Move walker by one step
 */
public void takeAStep(Graph g,NetworkSample ns){
  Map<Node,Collection<Node>> cc=this.getCurrentCandidates(g);
  Set<Node> c=cc.keySet();
  for (  Node n : c) {
    Collection<Node> candidates=controller.filterCandidates(cc.get(n),ns);
    Node next=this.selectNextNode(candidates);
    currents.remove(n);
    currents.add(next);
  }
}

Fixed version (ground truth):
/** 
 * Move walker by one step
 */
public void takeAStep(Graph g,NetworkSample ns){
}
Program: 39721
Project: 39721
Buggy source:
/** 
 * Get new nodes for restarting the walk if the walker blocks
 * @return collection of new start nodes
 */
protected Collection<Node> getRestartNodes(){
  return this.controller.getRestartNodes();
}

Fixed version (ground truth):
/** 
 * @return
 */
private Collection<Node> getRestartNodes(){
  return this.controller.getRestartNodes();
}
Program: 39722
Project: 39722
Buggy source:
/** 
 * This default implementation returns the list of neighbors as candidates
 * @param g Graph
 * @param n Current node
 * @return List of candidates
 */
private Collection<Node> resolveCandidates(Graph g,Node n){
  int[] nids=n.getOutgoingEdges();
  ArrayList<Node> nn=new ArrayList<Node>();
  for (  int i : nids) {
    nn.add(g.getNode(i));
  }
  return nn;
}

Fixed version (ground truth):
/** 
 * This default implementation returns the list of neighbors as candidates
 * @param g Graph
 * @param n Current node
 * @return List of candidates
 */
private Collection<Node> resolveCandidates(Graph g,Node n){
}
Program: 39723
Project: 39723
Buggy source:
public AWalkerController(String walkercontroller,Collection<AWalker> w,CandidateFilter cf){
  super("String_Node_Str",walkercontroller);
  walkers=w;
  candidateFilter=cf;
}

Fixed version (ground truth):
public AWalkerController(String walkercontroller,Collection<AWalker> w,CandidateFilter cf,StartNodeSelector sns){
  super("String_Node_Str",walkercontroller);
  this.walkers=w;
  this.candidateFilter=cf;
  this.startNodeSelector=sns;
}
Program: 39724
Project: 39724
Buggy source:
/** 
 * get new start nodes for restarting a walker instance
 * @return collection of new start nodes
 */
public Collection<Node> getRestartNodes(){
  Node[] rn;
  Collection<Node> frn, c;
  do {
    rn=samplingController.getStartNodeSelector().selectStartNodes(this.getGraph(),1,samplingController.getRng());
    c=Arrays.asList(rn);
    frn=filterCandidates(c);
  }
 while (frn.size() == 0);
  return frn;
}

Fixed version (ground truth):
/** 
 * @return
 */
public Collection<Node> getRestartNodes(){
  Node[] rn;
  Collection<Node> frn, c;
  do {
    rn=startNodeSelector.selectStartNodes(graph,1);
    c=Arrays.asList(rn);
    frn=filterCandidates(c,currentSample);
  }
 while (frn.size() == 0);
  return frn;
}
Program: 39725
Project: 39725
Buggy source:
/** 
 * Perform one step of walking with all active walker. The number of active walkers depends on the used walking-strategy
 */
public void walkOneStep(Graph g,NetworkSample ns){
  if (!isInitialized()) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  Collection<AWalker> activeWalkers=this.getActiveWalkers();
  for (  AWalker w : activeWalkers) {
    w.takeAStep(g,ns);
  }
}

Fixed version (ground truth):
/** 
 * Perform one step of walking with all active walker. The number of active walkers depends on the used walking-strategy
 */
public void walkOneStep(Graph g,NetworkSample ns){
  this.setCurrentSample(ns);
  if (!isInitialized()) {
    throw new IllegalStateException("String_Node_Str");
  }
  Collection<AWalker> activeWalkers=this.getActiveWalkers();
  for (  AWalker w : activeWalkers) {
    w.takeAStep(g,ns);
  }
}
Program: 39726
Project: 39726
Buggy source:
public static SamplingController getInstanceOf(SamplingAlgorithm sg,double scaledown,boolean revisiting,int dimension){
  SamplingController sc;
  ASampler as;
  AWalker aw;
  AWalkerController awc;
  CandidateFilter cf;
  NetworkSample ns;
  StartNodeSelector sns;
  String algorithm;
switch (sg) {
case UNIFORMSAMPLING:
    as=new VisitedNodeSampler();
  aw=new UniformRandomWalker();
cf=new CandidateFilter(revisiting);
Collection<AWalker> cw=new ArrayList<AWalker>();
cw.add(aw);
awc=new UniformSamplingWalkerController(cw,cf);
aw.setWalkerController(awc);
as.setWalkerController(awc);
sns=new StartNodeSelector("String_Node_Str");
algorithm="String_Node_Str";
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
sc=new SamplingController(algorithm,awc,as,sns,scaledown,dimension,revisiting);
return sc;
}

Fixed version (ground truth):
public static SamplingController getInstanceOf(SamplingAlgorithm sg,double scaledown,boolean revisiting,int dimension){
  SamplingController sc;
  ASampler as;
  AWalker aw;
  AWalkerController awc;
  CandidateFilter cf;
  NetworkSample ns;
  StartNodeSelector sns;
  String algorithm;
switch (sg) {
case UNIFORMSAMPLING:
    as=new VisitedNodeSampler();
  aw=new UniformRandomWalker();
cf=new CandidateFilter(revisiting);
sns=new StartNodeSelector("String_Node_Str");
Collection<AWalker> cw=new ArrayList<AWalker>();
cw.add(aw);
awc=new UniformSamplingWalkerController(cw,cf,sns);
aw.setWalkerController(awc);
as.setWalkerController(awc);
algorithm="String_Node_Str";
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
sc=new SamplingController(algorithm,awc,as,sns,scaledown,dimension,revisiting);
return sc;
}
Program: 39727
Project: 39727
Buggy source:
public boolean sampleGraph(Graph g){
  Node[] startNodes=startNodeSelector.selectStartNodes(g,dimension);
  int targetSampleSize=(int)Math.ceil(g.getNodeCount() * scaledown);
  int maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
  int round=0;
  walkerController.initialize(g,startNodes);
  sampler.initialize(g,networkSample,targetSampleSize);
  sampleOneStep(g,maxNodesInThisRound,round);
  boolean running=true;
  do {
    round++;
    walkerController.walkOneStep(g,networkSample);
    sampleOneStep(g,maxNodesInThisRound,round);
    maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
    running=(maxNodesInThisRound > 0) ? true : false;
  }
 while (running);
  return true;
}

Fixed version (ground truth):
public boolean sampleGraph(Graph g){
  Node[] startNodes=startNodeSelector.selectStartNodes(g,dimension);
  int targetSampleSize=(int)Math.ceil(g.getNodeCount() * scaledown);
  int maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
  int round=0;
  walkerController.initialize(g,startNodes);
  sampler.initialize(g,networkSample,targetSampleSize);
  walkerController.setGraph(g);
  sampleOneStep(g,maxNodesInThisRound,round);
  boolean running=true;
  do {
    round++;
    System.out.println("String_Node_Str" + round);
    walkerController.walkOneStep(g,networkSample);
    System.out.println("String_Node_Str");
    sampleOneStep(g,maxNodesInThisRound,round);
    System.out.println("String_Node_Str");
    maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
    running=(maxNodesInThisRound > 0) ? true : false;
  }
 while (running);
  return true;
}
Program: 39728
Project: 39728
Buggy source:
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=new Random();
  int next=r.nextInt(candidates.size() - 1);
  return candidates.toArray(new Node[0])[next];
}

Fixed version (ground truth):
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=new Random();
  int next=r.nextInt(candidates.size());
  next=next % candidates.size();
  return candidates.toArray(new Node[0])[next];
}
Program: 39729
Project: 39729
Buggy source:
/** 
 * @param key
 * @param value
 * @param w
 * @param cf
 */
public UniformSamplingWalkerController(Collection<AWalker> w,CandidateFilter cf){
  super(w.size() + "String_Node_Str" + w.toArray(new AWalker[0])[0].getValue(),w,cf);
  this.walkers=w;
  this.cf=cf;
}

Fixed version (ground truth):
/** 
 * @param key
 * @param value
 * @param w
 * @param cf
 */
public UniformSamplingWalkerController(Collection<AWalker> w,CandidateFilter cf,StartNodeSelector sns){
  super(w.size() + "String_Node_Str" + w.toArray(new AWalker[0])[0].getValue(),w,cf,sns);
  this.walkers=w;
  this.cf=cf;
}
Program: 39730
Project: 39730
Buggy source:
public Collection<Node> sampleOneStepNodes(int maxNodes){
  Collection<AWalker> walkers=walkerController.getActiveWalkers();
  Collection<Node> sampled=new LinkedList<Node>();
  for (  AWalker w : walkers) {
    Map<Node,Collection<Node>> wcc=w.getCurrentCandidates();
    Map<Node,Collection<Node>> fc=walkerController.filterCandidates(wcc);
    sampled.addAll(sampleNodes(fc));
  }
  return sampled;
}

Fixed version (ground truth):
public Collection<Node> sampleOneStepNodes(Graph g,NetworkSample ns,int maxNodes){
}
Program: 39731
Project: 39731
Buggy source:
/** 
 * Initializes the ASampler implementation This default implementation calls sampleOneStepNodes to sample the startnode(s)!
 * @param targetSampleSize  max nodes sampled in this round 
 * @param walkerController 
 */
public Collection<Node> initialize(AWalkerController walkerController,int maxNodes){
  this.walkerController=walkerController;
  return sampleOneStepNodes(maxNodes);
}

Fixed version (ground truth):
/** 
 * Initializes the ASampler implementation This default implementation calls sampleOneStepNodes to sample the startnode(s)!
 * @param targetSampleSize  max nodes sampled in this round 
 * @param walkerController 
 */
public Collection<Node> initialize(Graph g,NetworkSample ns,int maxNodes){
  return sampleOneStepNodes(g,ns,maxNodes);
}
Program: 39732
Project: 39732
Buggy source:
/** 
 * Set the used walker controller instance
 * @param awc
 */
public void setWalkerController(AWalkerController awc){
  this.walkerController=awc;
}

Fixed version (ground truth):
public void setWalkerController(AWalkerController awc){
  this.walkerController=awc;
}
Program: 39733
Project: 39733
Buggy source:
/** 
 * Returns the current neighbors of current nodes of the walker
 * @return Map: key: current node value: neighbors of the current node
 */
private Map<Node,Collection<Node>> getCurrentCandidates(Graph g){
  Map<Node,Collection<Node>> cn=new HashMap<Node,Collection<Node>>();
  for (  Node n : currents) {
    Collection<Node> nn=resolveCandidates(g,n);
    cn.put(n,nn);
  }
  return cn;
}

Fixed version (ground truth):
/** 
 * Returns the current neighbors of current nodes of the walker
 * @return Map: key: current node value: neighbors of the current node
 */
public Map<Node,Collection<Node>> getCurrentCandidates(Graph g){
  Map<Node,Collection<Node>> cn=new HashMap<Node,Collection<Node>>();
  for (  Node n : currents) {
    Collection<Node> nn=resolveCandidates(g,n);
    cn.put(n,nn);
  }
  return cn;
}
Program: 39734
Project: 39734
Buggy source:
/** 
 * @param key
 * @param value
 */
public NetworkSample(String key,String value){
  super(key,value);
  sampleNodeMapping=new HashMap<Integer,Integer>();
  revisitFrequency=new HashMap<Integer,List<Integer>>();
}

Fixed version (ground truth):
/** 
 * @param key
 * @param value
 */
public NetworkSample(){
  super("String_Node_Str","String_Node_Str");
  sampleNodeMapping=new HashMap<Integer,Integer>();
  revisitFrequency=new HashMap<Integer,List<Integer>>();
}
Program: 39735
Project: 39735
Buggy source:
public static SamplingController getInstanceOf(SamplingAlgorithm sg,double scaledown,boolean revisiting,int dimension){
  SamplingController sc;
  ASampler as;
  AWalker aw;
  AWalkerController awc;
  CandidateFilter cf;
  NetworkSample ns;
  StartNodeSelector sns;
  String algorithm;
switch (sg) {
case UNIFORMSAMPLING:
    as=new VisitedNodeSampler();
  aw=new UniformRandomWalker();
cf=new CandidateFilter(revisiting);
Collection<AWalker> cw=new ArrayList<AWalker>();
cw.add(aw);
awc=new UniformSamplingWalkerController(cw,cf);
aw.setWalkerController(awc);
sns=new StartNodeSelector("String_Node_Str");
algorithm="String_Node_Str";
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
sc=new SamplingController(algorithm,awc,as,sns,scaledown,dimension,revisiting);
return sc;
}

Fixed version (ground truth):
public static SamplingController getInstanceOf(SamplingAlgorithm sg,double scaledown,boolean revisiting,int dimension){
  SamplingController sc;
  ASampler as;
  AWalker aw;
  AWalkerController awc;
  CandidateFilter cf;
  NetworkSample ns;
  StartNodeSelector sns;
  String algorithm;
switch (sg) {
case UNIFORMSAMPLING:
    as=new VisitedNodeSampler();
  aw=new UniformRandomWalker();
cf=new CandidateFilter(revisiting);
Collection<AWalker> cw=new ArrayList<AWalker>();
cw.add(aw);
awc=new UniformSamplingWalkerController(cw,cf);
aw.setWalkerController(awc);
as.setWalkerController(awc);
sns=new StartNodeSelector("String_Node_Str");
algorithm="String_Node_Str";
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
sc=new SamplingController(algorithm,awc,as,sns,scaledown,dimension,revisiting);
return sc;
}
Program: 39736
Project: 39736
Buggy source:
public boolean sampleGraph(Graph g){
  Node[] startNodes=startNodeSelector.selectStartNodes(g,dimension);
  int targetSampleSize=(int)Math.ceil(g.getNodeCount() * scaledown);
  int maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
  int round=0;
  walkerController.initialize(g,startNodes);
  sampler.initialize(walkerController,targetSampleSize);
  sampleOneStep(maxNodesInThisRound,round);
  boolean running=true;
  do {
    round++;
    walkerController.walkOneStep();
    sampleOneStep(maxNodesInThisRound,round);
    maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
    running=(maxNodesInThisRound > 0) ? true : false;
  }
 while (running);
  return true;
}

Fixed version (ground truth):
public boolean sampleGraph(Graph g){
  Node[] startNodes=startNodeSelector.selectStartNodes(g,dimension);
  int targetSampleSize=(int)Math.ceil(g.getNodeCount() * scaledown);
  int maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
  int round=0;
  walkerController.initialize(g,startNodes);
  sampler.initialize(g,networkSample,targetSampleSize);
  sampleOneStep(g,maxNodesInThisRound,round);
  boolean running=true;
  do {
    round++;
    walkerController.walkOneStep(g,networkSample);
    sampleOneStep(g,maxNodesInThisRound,round);
    maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
    running=(maxNodesInThisRound > 0) ? true : false;
  }
 while (running);
  return true;
}
Program: 39737
Project: 39737
Buggy source:
/** 
 * Sample eventually nodes in the specified round
 * @param maxNodesInThisRound number of maximal added nodes
 * @param round current round
 * @return true if at least one node is sampled, else false
 */
private boolean sampleOneStep(int maxNodesInThisRound,int round){
  Collection<Node> chosenNodes=sampler.sampleOneStepNodes(maxNodesInThisRound);
  if (chosenNodes.size() > 0)   return networkSample.addNodeToSample(chosenNodes,round);
  return false;
}

Fixed version (ground truth):
/** 
 * Sample eventually nodes in the specified round
 * @param maxNodesInThisRound number of maximal added nodes
 * @param round current round
 * @return true if at least one node is sampled, else false
 */
private boolean sampleOneStep(Graph g,int maxNodesInThisRound,int round){
  Collection<Node> chosenNodes=sampler.sampleOneStepNodes(g,networkSample,maxNodesInThisRound);
  if (chosenNodes.size() > 0)   return networkSample.addNodeToSample(chosenNodes,round);
  return false;
}
Program: 39738
Project: 39738
Buggy source:
/** 
 * Select start nodes from the original graph The default implementation choses dimension random nodes
 * @param g 			Graph
 * @param dimension		Number of chosen startnodes
 * @return				Array of chosen startnodes
 */
public Node[] selectStartNodes(Graph g,int dimension){
  Collection<Node> sn=new ArrayList<Node>();
  Random r=new Random();
  int gsize=g.getNodeCount();
  int nid;
  Node n;
  int i=0;
  while (sn.size() < dimension) {
    nid=r.nextInt() % gsize;
    n=g.getNode(nid);
    if (!sn.contains(n)) {
      sn.add(n);
    }
  }
  return sn.toArray(new Node[dimension]);
}

Fixed version (ground truth):
/** 
 * Select start nodes from the original graph The default implementation choses dimension random nodes
 * @param g 			Graph
 * @param dimension		Number of chosen startnodes
 * @return				Array of chosen startnodes
 */
public Node[] selectStartNodes(Graph g,int dimension){
  Collection<Node> sn=new ArrayList<Node>();
  Random r=new Random();
  int gsize=g.getNodeCount();
  int nid;
  Node n;
  int i=0;
  while (sn.size() < dimension) {
    nid=r.nextInt(gsize - 1);
    nid=nid % gsize;
    n=g.getNode(nid);
    if (!sn.contains(n)) {
      sn.add(n);
    }
  }
  return sn.toArray(new Node[0]);
}
Program: 39739
Project: 39739
Buggy source:
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=new Random();
  int next=r.nextInt() % candidates.size();
  return candidates.toArray(new Node[0])[next];
}

Fixed version (ground truth):
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=new Random();
  int next=r.nextInt(candidates.size() - 1);
  return candidates.toArray(new Node[0])[next];
}
Program: 39740
Project: 39740
Buggy source:
/** 
 * @param args
 * @throws ParseException
 */
public static void main(String[] args) throws ParseException {
  for (  String s : args) {
    matchArgument(s);
  }
  GraphReader gr=null;
  if (snap) {
    gr=new SnapGraphReader();
  }
 else   if (caida) {
    gr=new CaidaGraphReader();
  }
  File f=new File(path);
  List<File> lof=Arrays.asList(f.listFiles());
  ArrayList<File> alof=new ArrayList<File>();
  ArrayList<String> names=new ArrayList<String>();
  for (  File fi : lof) {
    if (fi.isFile() && !fi.isHidden()) {
      alof.add(fi);
      names.add(fi.getName());
    }
  }
  File[] arlof=alof.toArray(new File[0]);
  String[] gNames=names.toArray(new String[0]);
  for (int i=0; i < arlof.length; i++) {
    Graph g=gr.read(arlof[i].getAbsolutePath());
    writeGraphToFile(g,path + "String_Node_Str" + gNames[i]);
    g=null;
  }
}

Fixed version (ground truth):
/** 
 * @param args
 * @throws ParseException
 * @throws IOException 
 */
public static void main(String[] args) throws ParseException, IOException {
  for (  String s : args) {
    matchArgument(s);
  }
  GraphReader gr=null;
  System.out.print("String_Node_Str");
  if (snap) {
    System.out.println("String_Node_Str");
    gr=new SnapGraphReader();
  }
 else   if (caida) {
    System.out.println("String_Node_Str");
    gr=new CaidaGraphReader();
  }
  System.out.println("String_Node_Str" + gr.hashCode());
  File f=new File(path);
  List<File> lof=Arrays.asList(f.listFiles());
  ArrayList<File> alof=new ArrayList<File>();
  ArrayList<String> names=new ArrayList<String>();
  for (  File fi : lof) {
    if (fi.isFile() && !fi.isHidden()) {
      System.out.println("String_Node_Str" + fi.getAbsolutePath());
      System.out.println("String_Node_Str" + fi.getName());
      alof.add(fi);
      names.add(fi.getName());
    }
  }
  for (int i=0; i < alof.size(); i++) {
    String p=alof.get(i).getAbsolutePath();
    System.out.println("String_Node_Str" + p);
    Graph g=gr.read(p);
    writeGraphToFile(g,path + "String_Node_Str" + names.get(i));
    g=null;
  }
}
Program: 39743
Project: 39743
Buggy source:
public static Network[] instantiateNetworkModels(){
  Network nw1=new ErdosRenyi(100,3,false,null);
  Network nw2=new BarabasiAlbert(500,2,null);
  Network nw3=new WattsStrogatz(500,6,0.2,null);
  Network nw4=new CondonAndKarp(500,3,0.05,0.0005,null);
  Network nw5=new Regular(100,2,true,false,null);
  Network[] n=new Network[]{nw4};
  return n;
}

Fixed version (ground truth):
public static Network[] instantiateNetworkModels(){
  Network nw1=new ErdosRenyi(100,3,false,null);
  Network nw2=new BarabasiAlbert(500,2,null);
  Network nw3=new WattsStrogatz(500,6,0.2,null);
  Network nw4=new CondonAndKarp(500,3,0.05,0.0005,null);
  Network nw5=new Regular(100,2,true,false,null);
  Network[] n=new Network[]{nw1};
  return n;
}
Program: 39745
Project: 39745
Buggy source:
/** 
 * Move walker one step
 */
public void takeAStep(Graph g,NetworkSample ns){
  Map<Node,Collection<Node>> cc=this.getCurrentCandidates();
  Collection<Node> c;
  if (cc.size() > 0) {
    c=cc.keySet();
  }
 else {
    System.err.println("String_Node_Str");
    c=getRestartNodes();
  }
  for (  Node n : c) {
    Collection<Node> candidates=new ArrayList<Node>();
    do {
      if (cc.size() > 0) {
        candidates=controller.filterCandidates(cc.get(n));
      }
 else {
        candidates=controller.filterCandidates(c);
      }
      if (candidates.size() == 0) {
        System.err.println("String_Node_Str");
        cc.clear();
        c=getRestartNodes();
      }
    }
 while (candidates.size() == 0);
    Node next=this.selectNextNode(candidates,n);
    currents.remove(n);
    currents.add(next);
  }
}

Fixed version (ground truth):
/** 
 * Move walker one step
 */
public void takeAStep(Graph g,NetworkSample ns){
  Map<Node,Collection<Node>> cc=this.getCurrentCandidates();
  Collection<Node> c;
  if (cc.size() > 0) {
    c=cc.keySet();
  }
 else {
    System.err.println("String_Node_Str");
    c=getRestartNodes();
  }
  for (  Node n : c) {
    Collection<Node> candidates=new ArrayList<Node>();
    do {
      if (cc.size() > 0) {
        candidates=controller.filterCandidates(cc.get(n));
      }
 else {
        candidates=controller.filterCandidates(c);
      }
      if (candidates.size() == 0) {
        System.err.println("String_Node_Str");
        cc.clear();
        c=getRestartNodes();
      }
    }
 while (candidates.size() == 0);
    Node next=this.selectNextNode(candidates);
    currents.remove(n);
    currents.add(next);
  }
}
Program: 39746
Project: 39746
Buggy source:
/** 
 * @param candidates
 * @return
 */
protected abstract Node selectNextNode(Collection<Node> candidates,Node current);

Fixed version (ground truth):
/** 
 * @param candidates
 * @return
 */
protected abstract Node selectNextNode(Collection<Node> candidates);
Program: 39747
Project: 39747
Buggy source:
@Override protected Node selectNextNode(Collection<Node> candidates,Node current){
  Random r=new Random();
  int next=r.nextInt(candidates.size());
  next=next % candidates.size();
  Node nextStepCandidate=candidates.toArray(new Node[0])[next];
  int nscDegree=nextStepCandidate.getDegree();
  int cDegree=current.getDegree();
  double d=(double)cDegree / (double)nscDegree;
  d=Math.min(d,1);
  double p=r.nextDouble();
  if (d < p) {
    return nextStepCandidate;
  }
 else {
    return current;
  }
}

Fixed version (ground truth):
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=this.getRNG();
  Collection<Node> c=this.getCurrentNodes();
  if (c.size() > 0) {
    Node current=c.toArray(new Node[0])[0];
    int next=r.nextInt(candidates.size());
    next=next % candidates.size();
    Node nextStepCandidate=candidates.toArray(new Node[0])[next];
    int nscDegree=nextStepCandidate.getDegree();
    int cDegree=current.getDegree();
    double d=(double)cDegree / (double)nscDegree;
    d=Math.min(d,1);
    double p=r.nextDouble();
    if (d < p) {
      return nextStepCandidate;
    }
 else {
      System.err.println("String_Node_Str" + cDegree + "String_Node_Str"+ nscDegree);
      return current;
    }
  }
 else {
    c=this.getRestartNodes();
    return c.toArray(new Node[0])[0];
  }
}
Program: 39748
Project: 39748
Buggy source:
/** 
 * @param args
 */
public static void main(String[] args){
  Config.overwrite("String_Node_Str","String_Node_Str");
  boolean get=false;
  int times=1;
  double scaledown=0.5;
  int dimension=1;
  boolean revisiting=false;
  Transformation uniformSampling=SamplingAlgorithmFactory.getInstanceOf(SamplingAlgorithm.UNIFORMSAMPLING,scaledown,revisiting,dimension);
  Transformation[] t=new Transformation[]{uniformSampling};
  Network nw1=new ErdosRenyi(10,3,false,t);
  Network[] n=new Network[]{nw1};
  Metric[] metrics=new Metric[]{new DegreeDistribution(),new ShortestPaths(),new ClusteringCoefficient()};
  Series[] s=get ? Series.get(n,metrics) : Series.generate(n,metrics,times);
  Plotting.single(s,metrics,"String_Node_Str");
  Plotting.multi(s,metrics,"String_Node_Str");
  for (  Network i : n) {
    System.out.println("String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes()+ "String_Node_Str");
    plot(i,"String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes(),times);
  }
}

Fixed version (ground truth):
/** 
 * @param args
 */
public static void main(String[] args){
  Config.overwrite("String_Node_Str","String_Node_Str");
  boolean get=false;
  int times=1;
  double scaledown=0.1;
  int dimension=1;
  boolean revisiting=false;
  Transformation uniformSampling=SamplingAlgorithmFactory.getInstanceOf(SamplingAlgorithm.UNIFORMSAMPLING,scaledown,revisiting,dimension);
  Transformation[] t=new Transformation[]{uniformSampling};
  Network nw1=new ErdosRenyi(10000,12,false,t);
  Network[] n=new Network[]{nw1};
  Metric[] metrics=new Metric[]{new DegreeDistribution(),new ShortestPaths(),new ClusteringCoefficient()};
  Series[] s=get ? Series.get(n,metrics) : Series.generate(n,metrics,times);
  Plotting.single(s,metrics,"String_Node_Str");
  Plotting.multi(s,metrics,"String_Node_Str");
  for (  Network i : n) {
    System.out.println("String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes()+ "String_Node_Str");
    plot(i,"String_Node_Str" + i.getKey() + "String_Node_Str"+ i.getNodes(),times);
  }
}
Program: 39749
Project: 39749
Buggy source:
/** 
 * @return
 */
public Collection<Node> sampleOneStepNodes(Graph g,NetworkSample ns,int maxNodes){
  Collection<AWalker> walkers=walkerController.getActiveWalkers();
  Collection<Node> sampled=new LinkedList<Node>();
  for (  AWalker w : walkers) {
    Map<Node,Collection<Node>> wcc=w.getCurrentCandidates(g);
    Map<Node,Collection<Node>> fc=walkerController.filterCandidates(wcc,ns);
    sampled.addAll(sampleNodes(fc));
  }
  return sampled;
}

Fixed version (ground truth):
/** 
 * @return
 */
public Collection<Node> sampleOneStepNodes(Graph g,NetworkSample ns,int maxNodes){
  Collection<AWalker> walkers=walkerController.getActiveWalkers();
  Collection<Node> sampled=new LinkedList<Node>();
  for (  AWalker w : walkers) {
    Map<Node,Collection<Node>> wcc=w.getCurrentCandidates(g);
    Map<Node,Collection<Node>> fc=walkerController.filterCandidates(wcc,ns);
    sampled.addAll(sampleNodes(fc));
  }
  System.out.println("String_Node_Str" + sampled.size() + "String_Node_Str");
  return sampled;
}
Program: 39750
Project: 39750
Buggy source:
/** 
 * Move walker by one step
 */
public void takeAStep(Graph g,NetworkSample ns){
  Map<Node,Collection<Node>> cc=this.getCurrentCandidates(g);
  Set<Node> c=cc.keySet();
  for (  Node n : c) {
    Collection<Node> candidates=controller.filterCandidates(cc.get(n),ns);
    Node next=this.selectNextNode(candidates);
    currents.remove(n);
    currents.add(next);
  }
}

Fixed version (ground truth):
/** 
 * Move walker by one step
 */
public void takeAStep(Graph g,NetworkSample ns){
  Map<Node,Collection<Node>> cc=this.getCurrentCandidates(g);
  Collection<Node> c;
  if (cc.size() > 0) {
    c=cc.keySet();
  }
 else {
    c=getRestartNodes();
  }
  for (  Node n : c) {
    Collection<Node> candidates=null;
    do {
      if (cc.size() > 0) {
        candidates=controller.filterCandidates(cc.get(n),ns);
      }
 else {
        candidates=controller.filterCandidates(c,ns);
      }
      if (candidates != null && candidates.size() == 0) {
        cc.clear();
        c=getRestartNodes();
      }
    }
 while (candidates.size() == 0);
    Node next=this.selectNextNode(candidates);
    System.out.println("String_Node_Str" + next);
    currents.remove(n);
    currents.add(next);
  }
}
Program: 39751
Project: 39751
Buggy source:
public AWalkerController(String walkercontroller,Collection<AWalker> w,CandidateFilter cf){
  super("String_Node_Str",walkercontroller);
  walkers=w;
  candidateFilter=cf;
}

Fixed version (ground truth):
public AWalkerController(String walkercontroller,Collection<AWalker> w,CandidateFilter cf,StartNodeSelector sns){
  super("String_Node_Str",walkercontroller);
  this.walkers=w;
  this.candidateFilter=cf;
  this.startNodeSelector=sns;
}
Program: 39752
Project: 39752
Buggy source:
/** 
 * Perform one step of walking with all active walker. The number of active walkers depends on the used walking-strategy
 */
public void walkOneStep(Graph g,NetworkSample ns){
  if (!isInitialized()) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  Collection<AWalker> activeWalkers=this.getActiveWalkers();
  for (  AWalker w : activeWalkers) {
    w.takeAStep(g,ns);
  }
}

Fixed version (ground truth):
/** 
 * Perform one step of walking with all active walker. The number of active walkers depends on the used walking-strategy
 */
public void walkOneStep(Graph g,NetworkSample ns){
  this.setCurrentSample(ns);
  if (!isInitialized()) {
    throw new IllegalStateException("String_Node_Str");
  }
  Collection<AWalker> activeWalkers=this.getActiveWalkers();
  for (  AWalker w : activeWalkers) {
    w.takeAStep(g,ns);
  }
}
Program: 39753
Project: 39753
Buggy source:
/** 
 * build an instance of a default sampling transformation
 * @param sg
 * @param revisiting
 * @param dimension IGNORED BY SINGLEDIMENSIONAL SAMPLING ALGORITHMS!
 * @return
 */
public static SamplingController getInstanceOf(SamplingAlgorithm sg,double scaledown,boolean revisiting,int dimension){
  SamplingController sc;
  ASampler as;
  AWalker aw;
  AWalkerController awc;
  CandidateFilter cf;
  NetworkSample ns;
  StartNodeSelector sns;
  String algorithm;
switch (sg) {
case UNIFORMSAMPLING:
    as=new VisitedNodeSampler();
  aw=new UniformRandomWalker();
cf=new CandidateFilter(revisiting);
Collection<AWalker> cw=new ArrayList<AWalker>();
cw.add(aw);
awc=new UniformSamplingWalkerController(cw,cf);
aw.setWalkerController(awc);
as.setWalkerController(awc);
sns=new StartNodeSelector("String_Node_Str");
algorithm="String_Node_Str";
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
sc=new SamplingController(algorithm,awc,as,sns,scaledown,dimension,revisiting);
return sc;
}

Fixed version (ground truth):
/** 
 * build an instance of a default sampling transformation
 * @param sg
 * @param revisiting
 * @param dimension IGNORED BY SINGLEDIMENSIONAL SAMPLING ALGORITHMS!
 * @return
 */
public static SamplingController getInstanceOf(SamplingAlgorithm sg,double scaledown,boolean revisiting,int dimension){
  SamplingController sc;
  ASampler as;
  AWalker aw;
  AWalkerController awc;
  CandidateFilter cf;
  NetworkSample ns;
  StartNodeSelector sns;
  String algorithm;
switch (sg) {
case UNIFORMSAMPLING:
    as=new VisitedNodeSampler();
  aw=new UniformRandomWalker();
cf=new CandidateFilter(revisiting);
sns=new StartNodeSelector("String_Node_Str");
Collection<AWalker> cw=new ArrayList<AWalker>();
cw.add(aw);
awc=new UniformSamplingWalkerController(cw,cf,sns);
aw.setWalkerController(awc);
as.setWalkerController(awc);
algorithm="String_Node_Str";
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
sc=new SamplingController(algorithm,awc,as,sns,scaledown,dimension,revisiting);
return sc;
}
Program: 39754
Project: 39754
Buggy source:
public boolean sampleGraph(Graph g){
  Node[] startNodes=startNodeSelector.selectStartNodes(g,dimension);
  int targetSampleSize=(int)Math.ceil(g.getNodeCount() * scaledown);
  int maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
  int round=0;
  walkerController.initialize(g,startNodes);
  sampler.initialize(g,networkSample,targetSampleSize);
  sampleOneStep(g,maxNodesInThisRound,round);
  boolean running=true;
  do {
    round++;
    walkerController.walkOneStep(g,networkSample);
    sampleOneStep(g,maxNodesInThisRound,round);
    maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
    running=(maxNodesInThisRound > 0) ? true : false;
  }
 while (running);
  return true;
}

Fixed version (ground truth):
public boolean sampleGraph(Graph g){
  Node[] startNodes=startNodeSelector.selectStartNodes(g,dimension);
  int targetSampleSize=(int)Math.ceil(g.getNodeCount() * scaledown);
  int maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
  int round=0;
  walkerController.initialize(g,startNodes);
  sampler.initialize(g,networkSample,targetSampleSize);
  walkerController.setGraph(g);
  sampleOneStep(g,maxNodesInThisRound,round);
  boolean running=true;
  do {
    round++;
    System.out.println("String_Node_Str" + round);
    walkerController.walkOneStep(g,networkSample);
    System.out.println("String_Node_Str");
    sampleOneStep(g,maxNodesInThisRound,round);
    System.out.println("String_Node_Str");
    maxNodesInThisRound=calculateResidualBudget(targetSampleSize);
    running=(maxNodesInThisRound > 0) ? true : false;
  }
 while (running);
  return true;
}
Program: 39755
Project: 39755
Buggy source:
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=new Random();
  int next=r.nextInt(candidates.size() - 1);
  return candidates.toArray(new Node[0])[next];
}

Fixed version (ground truth):
@Override protected Node selectNextNode(Collection<Node> candidates){
  Random r=new Random();
  int next=r.nextInt(candidates.size());
  next=next % candidates.size();
  return candidates.toArray(new Node[0])[next];
}
Program: 39756
Project: 39756
Buggy source:
/** 
 * @param key
 * @param value
 * @param w
 * @param cf
 */
public UniformSamplingWalkerController(Collection<AWalker> w,CandidateFilter cf){
  super(w.size() + "String_Node_Str" + w.toArray(new AWalker[0])[0].getValue(),w,cf);
  this.walkers=w;
  this.cf=cf;
}

Fixed version (ground truth):
/** 
 * @param key
 * @param value
 * @param w
 * @param cf
 */
public UniformSamplingWalkerController(Collection<AWalker> w,CandidateFilter cf,StartNodeSelector sns){
  super(w.size() + "String_Node_Str" + w.toArray(new AWalker[0])[0].getValue(),w,cf,sns);
  this.walkers=w;
  this.cf=cf;
}
Program: 39757
Project: 39757
Buggy source:
/** 
 * @return
 */
public Collection<Node> sampleOneStepNodes(int maxNodes){
  Collection<AWalker> walkers=walkerController.getActiveWalkers();
  Collection<Node> sampled=new LinkedList<Node>();
  for (  AWalker w : walkers) {
    Map<Node,Collection<Node>> wcc=w.getCurrentCandidates();
    Map<Node,Collection<Node>> fc=walkerController.filterCandidates(wcc);
    sampled.addAll(sampleNodes(fc));
  }
  return sampled;
}

Fixed version (ground truth):
/** 
 * @return
 */
public Collection<Node> sampleOneStepNodes(Graph g,NetworkSample ns,int maxNodes){
  Collection<AWalker> walkers=walkerController.getActiveWalkers();
  Collection<Node> sampled=new LinkedList<Node>();
  for (  AWalker w : walkers) {
    Map<Node,Collection<Node>> wcc=w.getCurrentCandidates(g);
    Map<Node,Collection<Node>> fc=walkerController.filterCandidates(wcc,ns);
    sampled.addAll(sampleNodes(fc));
  }
  return sampled;
}
Program: 39758
Project: 39758
Buggy source:
/** 
 * Initializes the ASampler implementation This default implementation calls sampleOneStepNodes to sample the startnode(s)!
 * @param targetSampleSize  max nodes sampled in this round 
 * @param walkerController 
 */
public Collection<Node> initialize(AWalkerController walkerController,int maxNodes){
  this.walkerController=walkerController;
  return sampleOneStepNodes(maxNodes);
}

Fixed version (ground truth):
/** 
 * Initializes the ASampler implementation This default implementation calls sampleOneStepNodes to sample the startnode(s)!
 * @param targetSampleSize  max nodes sampled in this round 
 * @param walkerController 
 */
public Collection<Node> initialize(Graph g,NetworkSample ns,int maxNodes){
  return sampleOneStepNodes(g,ns,maxNodes);
}
Program: 39759
Project: 39759
Buggy source:
/** 
 * Returns the current neighbors of current nodes of the walker
 * @return Map: key: current node value: neighbors of the current node
 */
private Map<Node,Collection<Node>> getCurrentCandidates(Graph g){
  Map<Node,Collection<Node>> cn=new HashMap<Node,Collection<Node>>();
  for (  Node n : currents) {
    Collection<Node> nn=resolveCandidates(g,n);
    cn.put(n,nn);
  }
  return cn;
}

Fixed version (ground truth):
/** 
 * Returns the current neighbors of current nodes of the walker
 * @return Map: key: current node value: neighbors of the current node
 */
public Map<Node,Collection<Node>> getCurrentCandidates(Graph g){
  Map<Node,Collection<Node>> cn=new HashMap<Node,Collection<Node>>();
  for (  Node n : currents) {
    Collection<Node> nn=resolveCandidates(g,n);
    cn.put(n,nn);
  }
  return cn;
}
Program: 39760
Project: 39760
Buggy source:
/** 
 * @param key
 * @param value
 */
public NetworkSample(String key,String value){
  super(key,value);
  sampleNodeMapping=new HashMap<Integer,Integer>();
  revisitFrequency=new HashMap<Integer,List<Integer>>();
}

Fixed version (ground truth):
/** 
 * @param key
 * @param value
 */
public NetworkSample(){
  super("String_Node_Str","String_Node_Str");
  sampleNodeMapping=new HashMap<Integer,Integer>();
  revisitFrequency=new HashMap<Integer,List<Integer>>();
}