Program: 190157
Project: 190157
Buggy source:
private void exportData(Graph graph) throws Exception {
  stringBuilder=new StringBuilder();
  int max=graph.getNodeCount();
  Progress.start(progressTicket,max);
  if (!list) {
    if (header) {
      stringBuilder.append(SEPARATOR);
      for (      Node n : graph.getNodes()) {
        writeMatrixNode(n);
      }
      stringBuilder.deleteCharAt(stringBuilder.length() - 1);
      stringBuilder.append(EOL);
    }
  }
  if (list) {
    for (    Node n : graph.getNodes()) {
      writeListNode(n);
      for (      Edge e : graph.getEdges(n)) {
        if (!e.isDirected() || (e.isDirected() && n == e.getSource())) {
          Node m=graph.getOpposite(n,e);
          writeListNode(m);
        }
      }
      stringBuilder.deleteCharAt(stringBuilder.length() - 1);
      stringBuilder.append(EOL);
    }
  }
 else {
    if (graph instanceof DirectedGraph) {
      DirectedGraph directedGraph=(DirectedGraph)graph;
      for (      Node n : graph.getNodes()) {
        if (cancel) {
          break;
        }
        writeMatrixNode(n);
        for (        Node m : graph.getNodes()) {
          Edge e=directedGraph.getEdge(n,m);
          writeEdge(e);
        }
        Progress.progress(progressTicket);
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        stringBuilder.append(EOL);
      }
    }
 else     if (graph instanceof UndirectedGraph) {
      UndirectedGraph undirectedGraph=(UndirectedGraph)graph;
      for (      Node n : graph.getNodes()) {
        if (cancel) {
          break;
        }
        writeMatrixNode(n);
        for (        Node m : graph.getNodes()) {
          Edge e=undirectedGraph.getEdge(n,m);
          writeEdge(e);
        }
        Progress.progress(progressTicket);
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        stringBuilder.append(EOL);
      }
    }
 else {
      MixedGraph mixedGraph=(MixedGraph)graph;
      for (      Node n : graph.getNodes()) {
        if (cancel) {
          break;
        }
        writeMatrixNode(n);
        for (        Node m : graph.getNodes()) {
          Edge e=mixedGraph.getEdge(n,m);
          writeEdge(e);
        }
        Progress.progress(progressTicket);
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        stringBuilder.append(EOL);
      }
    }
  }
  if (!cancel) {
    writer.append(stringBuilder);
  }
  graph.readUnlockAll();
  Progress.finish(progressTicket);
}

Fixed version (ground truth):
private void exportData(Graph graph) throws Exception {
  int max=graph.getNodeCount();
  Progress.start(progressTicket,max);
  if (!list) {
    if (header) {
      writer.append(SEPARATOR);
      Node[] nodes=graph.getNodes().toArray();
      for (int i=0; i < nodes.length; i++) {
        writeMatrixNode(nodes[i],i < nodes.length - 1);
      }
      writer.append(EOL);
    }
  }
  if (list) {
    Node[] nodes=graph.getNodes().toArray();
    for (int i=0; i < nodes.length; i++) {
      Node n=nodes[i];
      List<Node> neighbours=new ArrayList<Node>();
      for (      Edge e : graph.getEdges(n)) {
        if (!e.isDirected() || (e.isDirected() && n == e.getSource())) {
          Node m=graph.getOpposite(n,e);
          neighbours.add(m);
        }
      }
      writeListNode(n,!neighbours.isEmpty());
      for (int j=0; j < neighbours.size(); j++) {
        writeListNode(neighbours.get(j),j < neighbours.size() - 1);
      }
      writer.append(EOL);
    }
  }
 else {
    if (graph instanceof DirectedGraph) {
      DirectedGraph directedGraph=(DirectedGraph)graph;
      Node[] nodes=graph.getNodes().toArray();
      for (      Node n : nodes) {
        if (cancel) {
          break;
        }
        writeMatrixNode(n,true);
        for (int j=0; j < nodes.length; j++) {
          Node m=nodes[j];
          Edge e=directedGraph.getEdge(n,m);
          writeEdge(e,j < nodes.length - 1);
        }
        Progress.progress(progressTicket);
        writer.append(EOL);
      }
    }
 else     if (graph instanceof UndirectedGraph) {
      UndirectedGraph undirectedGraph=(UndirectedGraph)graph;
      Node[] nodes=graph.getNodes().toArray();
      for (      Node n : nodes) {
        if (cancel) {
          break;
        }
        writeMatrixNode(n,true);
        for (int j=0; j < nodes.length; j++) {
          Node m=nodes[j];
          Edge e=undirectedGraph.getEdge(n,m);
          writeEdge(e,j < nodes.length - 1);
        }
        Progress.progress(progressTicket);
        writer.append(EOL);
      }
    }
 else {
      MixedGraph mixedGraph=(MixedGraph)graph;
      Node[] nodes=graph.getNodes().toArray();
      for (      Node n : graph.getNodes()) {
        if (cancel) {
          break;
        }
        writeMatrixNode(n,true);
        for (int j=0; j < nodes.length; j++) {
          Node m=nodes[j];
          Edge e=mixedGraph.getEdge(n,m);
          writeEdge(e,j < nodes.length - 1);
        }
        Progress.progress(progressTicket);
        writer.append(EOL);
      }
    }
  }
  graph.readUnlockAll();
  Progress.finish(progressTicket);
}