@Override
	public void toDot(String filename) {
		monitor.println("Writing " + filename);
		BufferedWriter w = null;
		try {
			FileWriter fstream = new FileWriter(filename);
			w = new BufferedWriter(fstream);
		
			w.write("digraph G {\n");
			
			// nodes
			for (ItemPair p : done) {
				String id = Util.dotId(toString(p));
				String s = id + "[label=" + id;
				if (p.isStartOrEndPair()) {
					s += ", style=filled,fillcolor=orange";
				}
				s += "];\n";
				w.write(s);
			}
			
			// edges
			for (PairTransition t : transitions) {
				String dot = Util.dotId(toString(t.source)) + " -> " + Util.dotId(toString(t.target)) + " [";
				dot += "label=" + Util.dotId(t);
				if (potentialAmbiguities.contains(t)) {
					dot += ",color=red";
				}
				dot += "];\n";
				w.write(dot);
			}
			w.write("}\n");
			
		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
		} finally {
			if (w != null) {
				try {
					w.close();
				} catch (IOException e) { }
			}
		}
	}