Fix DAG.flatten

* Reuse `to_nodes` variable.
* Handle graphs with multiple nodes pointing to a single
  node.  (Someone forgot to populate `visited_nodes`.)
Use `head -n1` instead of `cat`

With really long and somewhat wide graphs, the root files
ended up being very large.

Using `head -n1` keeps the cost of each build approximately
proportional to the number of inputs.
Fix DAG sorting for Tup build

flatten() wasn't a proper topological sort.  flatten()
happens to work with existing graphs because there are no
two nodes pointing to the same third node.  Use a proper
topological sort instead.
DAG.dump() method for easier manual testing
Test LLVM and Chromium graphs

The graphs were imported from open-source projects.

The graphs do not work with FixedIncrementalSetup yet.

LLVM:

    cmake -G Ninja
    ninja -t graph > llvm.dot

Chromium:

    ./build/gyp_chromium
    ninja -C out/Debug -t graph > llvm.dot

Currently the build files generated are not very accurate if
explicit dependencies (e.g. header files) are checked into
the source repository.  Impact of this inaccuracy is
unknown.