Program: 145931
Project: 145931
Buggy source:
public Graph partition2graph_binary(){
  ArrayList<Integer> renumber=new ArrayList<Integer>(size);
  Util.initArrayList(renumber,-1);
  for (int node=0; node < size; node++) {
    renumber.set(n2c.get(node),renumber.get(n2c.get(node)) + 1);
  }
  int fin=0;
  for (int i=0; i < size; i++)   if (renumber.get(i) != -1) {
    renumber.set(i,fin++);
  }
  ArrayList<ArrayList<Integer>> comm_nodes=new ArrayList<ArrayList<Integer>>(fin);
  n2c_new.getList().clear();
  for (int node=0; node < size; node++) {
    if (comm_nodes.get(renumber.get(n2c.get(node))) == null) {
      comm_nodes.set(renumber.get(n2c.get(node)),new ArrayList<Integer>());
    }
    comm_nodes.get(renumber.get(n2c.get(node))).add(node);
    n2c_new.setRandom(node,renumber.get(n2c.get(node)));
  }
  Graph g2=new Graph();
  g2.setNb_nodes(comm_nodes.size());
  int comm_deg=comm_nodes.size();
  for (int comm=0; comm < comm_deg; comm++) {
    HashMap<Integer,Double> m=new HashMap<Integer,Double>();
    int comm_size=comm_nodes.get(comm).size();
    for (int node=0; node < comm_size; node++) {
      Pair<Integer,Integer> p=g.neighbors(comm_nodes.get(comm).get(node));
      long deg=g.nb_neighbors(comm_nodes.get(comm).get(node));
      for (int i=0; i < deg; i++) {
        int neigh=g.getLinks().getList().get(p.getElement0() + i);
        int neigh_comm=renumber.get(n2c.get(neigh));
        double neigh_weight=(g.getWeights().size() == 0) ? 1. : g.getWeights().getList().get(p.getElement1() + i);
        ;
        if (!m.containsKey(neigh_comm)) {
          m.put(neigh_comm,neigh_weight);
        }
 else {
          m.put(neigh_comm,m.get(neigh_comm) + neigh_weight);
        }
      }
      if (g.isContainRemote()) {
        HashMap.SimpleEntry<Vector<Integer>,Vector<Float>> p2=g.remote_neighbors(comm_nodes.get(comm).get(node));
        deg=g.nb_remote_neighbors(comm_nodes.get(comm).get(node));
        for (int i=0; i < deg; i++) {
          int neigh=p2.getKey().getList().get(i);
          int neigh_comm=renumber.get(n2c.get(neigh));
          double neigh_weight=(g.getWeights().size() == 0) ? 1. : p2.getValue().getList().get(i);
          if (m.containsKey(neigh_comm)) {
            m.put(neigh_comm,m.get(neigh_comm) + neigh_weight);
          }
 else {
            m.put(neigh_comm,neigh_weight);
          }
        }
      }
    }
    g2.getDegrees().getList().add(comm,(comm == 0) ? m.size() : g2.getDegrees().getList().get(comm - 1) + m.size());
    g2.setNb_links(g2.getNb_links() + m.size());
    Iterator<Integer> it=m.keySet().iterator();
    while (it.hasNext()) {
      int key=it.next();
      double value=m.get(key);
      g2.setTotal_weight(g2.getTotal_weight() + value);
      g2.getLinks().getList().add(key);
      g2.getWeights().getList().add((float)value);
    }
  }
  return g2;
}

Fixed version (ground truth):
public Graph partition2graph_binary(){
  ArrayList<Integer> renumber=new ArrayList<Integer>(size);
  Util.initArrayList(renumber,size,-1);
  for (int node=0; node < size; node++) {
    renumber.set(n2c.get(node),renumber.get(n2c.get(node)) + 1);
  }
  int fin=0;
  for (int i=0; i < size; i++)   if (renumber.get(i) != -1) {
    renumber.set(i,fin++);
  }
  ArrayList<ArrayList<Integer>> comm_nodes=new ArrayList<ArrayList<Integer>>(fin);
  for (int i=0; i < fin; i++) {
    comm_nodes.add(null);
  }
  n2c_new.getList().clear();
  for (int node=0; node < size; node++) {
    if (comm_nodes.get(renumber.get(n2c.get(node))) == null) {
      comm_nodes.set(renumber.get(n2c.get(node)),new ArrayList<Integer>());
    }
    comm_nodes.get(renumber.get(n2c.get(node))).add(node);
    n2c_new.setRandom(node,renumber.get(n2c.get(node)));
  }
  Graph g2=new Graph();
  g2.setNb_nodes(comm_nodes.size());
  int comm_deg=comm_nodes.size();
  for (int comm=0; comm < comm_deg; comm++) {
    HashMap<Integer,Double> m=new HashMap<Integer,Double>();
    int comm_size=comm_nodes.get(comm).size();
    for (int node=0; node < comm_size; node++) {
      Pair<Integer,Integer> p=g.neighbors(comm_nodes.get(comm).get(node));
      long deg=g.nb_neighbors(comm_nodes.get(comm).get(node));
      for (int i=0; i < deg; i++) {
        int neigh=g.getLinks().getList().get(p.getElement0() + i);
        int neigh_comm=renumber.get(n2c.get(neigh));
        double neigh_weight=(g.getWeights().size() == 0) ? 1. : g.getWeights().getList().get(p.getElement1() + i);
        ;
        if (!m.containsKey(neigh_comm)) {
          m.put(neigh_comm,neigh_weight);
        }
 else {
          m.put(neigh_comm,m.get(neigh_comm) + neigh_weight);
        }
      }
      if (g.isContainRemote() && g.getRemoteEdges().containsKey(node)) {
        HashMap.SimpleEntry<Vector<Integer>,Vector<Float>> p2=g.remote_neighbors(comm_nodes.get(comm).get(node));
        deg=g.nb_remote_neighbors(comm_nodes.get(comm).get(node));
        for (int i=0; i < deg; i++) {
          int neigh=p2.getKey().getList().get(i);
          int neigh_comm=renumber.get(n2c.get(neigh));
          double neigh_weight=(g.getWeights().size() == 0) ? 1. : p2.getValue().getList().get(i);
          if (m.containsKey(neigh_comm)) {
            m.put(neigh_comm,m.get(neigh_comm) + neigh_weight);
          }
 else {
            m.put(neigh_comm,neigh_weight);
          }
        }
      }
    }
    g2.getDegrees().getList().add(comm,(comm == 0) ? m.size() : g2.getDegrees().getList().get(comm - 1) + m.size());
    g2.setNb_links(g2.getNb_links() + m.size());
    Iterator<Integer> it=m.keySet().iterator();
    while (it.hasNext()) {
      int key=it.next();
      double value=m.get(key);
      g2.setTotal_weight(g2.getTotal_weight() + value);
      g2.getLinks().getList().add(key);
      g2.getWeights().getList().add((float)value);
    }
  }
  g2.setRemoteMaps(g.getRemoteMaps());
  return g2;
}