Now detects rooted DAG and throws proper exceptions.