public void dependencyGraphToDot(String filename) {
		// TODO this should be productions i.s.o. nonterminals
		ShareableHashMap<NonTerminal, Set<NonTerminal>> dependencies = buildDependencyGraph(productions, nonTerminals.values());
		
		BufferedWriter w = null;
		try {
			FileWriter fstream = new FileWriter(filename);
			w = new BufferedWriter(fstream);
		
			w.write("digraph G {\n");
			
			for (Entry<NonTerminal, Set<NonTerminal>> e : dependencies.entrySet()) {
				NonTerminal n1 = e.getKey();
				if (n1.literal || n1.layout) {
					continue;
				}
				for (NonTerminal n2 : e.getValue()) {
					if (n2.literal || n2.layout) {
						continue;
					}
					w.write("" + Util.dotId(e.getKey()) + " -> " + Util.dotId(n2) + " ;\n");
				}
			}
			
			w.write("}\n");			
		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
		} finally {
			if (w != null) {
				try {
					w.close();
				} catch (IOException e) { }
			}
		}
	}