Program: 142827
Project: 142827
Buggy source:
public void closeLoader(){
  if (parameters.getEdgeDefault().equals(EdgeDefault.UNDIRECTED)) {
    for (Iterator<EdgeDraftImpl> itr=edgeMap.values().iterator(); itr.hasNext(); ) {
      EdgeDraftImpl edge=itr.next();
      String oppositekey=edge.getTarget().getId() + "String_Node_Str" + edge.getSource().getId();
      EdgeDraftImpl opposite=edgeSourceTargetMap.get(oppositekey);
      if (opposite != null) {
        if (parameters.isUndirectedSumDirectedEdgesWeight()) {
          opposite.setWeight(edge.getWeight() + opposite.getWeight());
        }
 else {
          opposite.setWeight(Math.max(edge.getWeight(),opposite.getWeight()));
        }
        itr.remove();
        edgeSourceTargetMap.remove(edge.getSource().getId() + "String_Node_Str" + edge.getTarget().getId());
      }
    }
  }
 else   if (parameters.getEdgeDefault().equals(EdgeDefault.MIXED)) {
    for (    EdgeDraftImpl edge : edgeMap.values().toArray(new EdgeDraftImpl[0])) {
      if (edge.getType() == null) {
        edge.setType(EdgeDraft.EdgeType.UNDIRECTED);
      }
      if (edge.getType().equals(EdgeDraft.EdgeType.UNDIRECTED)) {
        String oppositekey=edge.getTarget().getId() + "String_Node_Str" + edge.getSource().getId();
        EdgeDraftImpl opposite=edgeSourceTargetMap.get(oppositekey);
        if (opposite != null) {
          if (parameters.isUndirectedSumDirectedEdgesWeight()) {
            edge.setWeight(edge.getWeight() + opposite.getWeight());
          }
 else {
            edge.setWeight(Math.max(edge.getWeight(),opposite.getWeight()));
          }
          edgeMap.remove(opposite.getId());
          edgeSourceTargetMap.remove(oppositekey);
        }
      }
    }
  }
  if (!allowAutoNode()) {
    for (    NodeDraftImpl nodeDraftImpl : nodeMap.values().toArray(new NodeDraftImpl[0])) {
      if (nodeDraftImpl.isCreatedAuto()) {
        nodeMap.remove(nodeDraftImpl.getId());
        for (Iterator<EdgeDraftImpl> itr=edgeMap.values().iterator(); itr.hasNext(); ) {
          EdgeDraftImpl edge=itr.next();
          if (edge.getSource() == nodeDraftImpl || edge.getTarget() == nodeDraftImpl) {
            itr.remove();
          }
        }
      }
    }
  }
  LinkedHashMap<String,NodeDraftImpl> sortedNodeMap=new LinkedHashMap<String,NodeDraftImpl>();
  ArrayList<NodeDraftImpl> sortedMapValues=new ArrayList<NodeDraftImpl>(nodeMap.values());
  Collections.sort(sortedMapValues,new Comparator<NodeDraftImpl>(){
    public int compare(    NodeDraftImpl o1,    NodeDraftImpl o2){
      return new Integer(o2.getHeight()).compareTo(o1.getHeight());
    }
  }
);
  for (  NodeDraftImpl n : sortedMapValues) {
    sortedNodeMap.put(n.getId(),n);
  }
  nodeMap=sortedNodeMap;
  for (  NodeDraftImpl node : nodeMap.values()) {
    if (node.getLabel() == null) {
      node.setLabel(node.getId());
    }
  }
}

Fixed version (ground truth):
public void closeLoader(){
  if (parameters.getEdgeDefault().equals(EdgeDefault.UNDIRECTED)) {
    for (Iterator<EdgeDraftImpl> itr=edgeMap.values().iterator(); itr.hasNext(); ) {
      EdgeDraftImpl edge=itr.next();
      String oppositekey=edge.getTarget().getId() + "String_Node_Str" + edge.getSource().getId();
      EdgeDraftImpl opposite=edgeSourceTargetMap.get(oppositekey);
      if (opposite != null) {
        if (parameters.isUndirectedSumDirectedEdgesWeight()) {
          opposite.setWeight(edge.getWeight() + opposite.getWeight());
        }
 else {
          opposite.setWeight(Math.max(edge.getWeight(),opposite.getWeight()));
        }
        itr.remove();
        edgeSourceTargetMap.remove(edge.getSource().getId() + "String_Node_Str" + edge.getTarget().getId());
      }
    }
  }
 else   if (parameters.getEdgeDefault().equals(EdgeDefault.MIXED)) {
    for (    EdgeDraftImpl edge : edgeMap.values().toArray(new EdgeDraftImpl[0])) {
      if (edge.getType() == null) {
        edge.setType(EdgeDraft.EdgeType.UNDIRECTED);
      }
      if (edge.getType().equals(EdgeDraft.EdgeType.UNDIRECTED)) {
        String oppositekey=edge.getTarget().getId() + "String_Node_Str" + edge.getSource().getId();
        EdgeDraftImpl opposite=edgeSourceTargetMap.get(oppositekey);
        if (opposite != null) {
          if (parameters.isUndirectedSumDirectedEdgesWeight()) {
            edge.setWeight(edge.getWeight() + opposite.getWeight());
          }
 else {
            edge.setWeight(Math.max(edge.getWeight(),opposite.getWeight()));
          }
          edgeMap.remove(opposite.getId());
          edgeSourceTargetMap.remove(oppositekey);
        }
      }
    }
  }
  if (!allowAutoNode()) {
    for (    NodeDraftImpl nodeDraftImpl : nodeMap.values().toArray(new NodeDraftImpl[0])) {
      if (nodeDraftImpl.isCreatedAuto()) {
        nodeMap.remove(nodeDraftImpl.getId());
        for (Iterator<EdgeDraftImpl> itr=edgeMap.values().iterator(); itr.hasNext(); ) {
          EdgeDraftImpl edge=itr.next();
          if (edge.getSource() == nodeDraftImpl || edge.getTarget() == nodeDraftImpl) {
            itr.remove();
          }
        }
      }
    }
  }
  LinkedHashMap<String,NodeDraftImpl> sortedNodeMap=new LinkedHashMap<String,NodeDraftImpl>();
  ArrayList<NodeDraftImpl> sortedMapValues=new ArrayList<NodeDraftImpl>(nodeMap.values());
  Collections.sort(sortedMapValues,new Comparator<NodeDraftImpl>(){
    public int compare(    NodeDraftImpl o1,    NodeDraftImpl o2){
      return new Integer(o2.getHeight()).compareTo(o1.getHeight());
    }
  }
);
  for (  NodeDraftImpl n : sortedMapValues) {
    sortedNodeMap.put(n.getId(),n);
  }
  nodeMap=sortedNodeMap;
  for (  NodeDraftImpl node : nodeMap.values()) {
    if (node.getLabel() == null) {
      node.setLabel(node.getId());
    }
  }
  boolean customPosition=false;
  for (  NodeDraftImpl node : nodeMap.values()) {
    if (Float.isNaN(node.getX())) {
      node.setX(0);
    }
    if (Float.isNaN(node.getY())) {
      node.setY(0);
    }
    if (Float.isNaN(node.getZ())) {
      node.setZ(0);
    }
    if (node.getX() != 0f || node.getY() != 0) {
      customPosition=true;
    }
  }
  if (!customPosition) {
    for (    NodeDraftImpl node : nodeMap.values()) {
      node.setX((float)((0.01 + Math.random()) * 1000) - 500);
      node.setY((float)((0.01 + Math.random()) * 1000) - 500);
    }
  }
}