public <V, E> void export(
			TGFProvider<? super V, ? super E> provider,
			Digraph<? extends V, ? extends E> digraph,
			Writer writer) throws IOException {
		Map<V, Integer> index = new HashMap<V, Integer>();
		int n = 0;
		for (V vertex : digraph.vertices()) {
			++n;
			index.put(vertex, n);
			writer.write(String.valueOf(n));
			String label = provider.getVertexLabel(vertex);
			if (label != null) {
				writer.write(' ');
				writer.write(label);
			}
			writer.write(newline);
		}
		writer.write('#');
		writer.write(newline);
		for (V source : digraph.vertices()) {
			for (V target : digraph.targets(source)) {
				writer.write(String.valueOf(index.get(source)));
				writer.write(' ');
				writer.write(String.valueOf(index.get(target)));
				String label = provider.getEdgeLabel(digraph.get(source, target));
				if (label != null) {
					writer.write(' ');
					writer.write(label);
				}
				writer.write(newline);
			}
		}
		writer.flush();
	}