Not very common, but sometimes invalid DAG is generated. (e.g. total node number < start node + end node) Update to code to check these invalidness.