fix layout
assert that the graph is indeed a DAG