Extremely Basic DAG algorithm.