check error messages emitted by topoSort()
topoSort() returns NULL when a cycle detects, as described in the comment