In topological sort: check all nodes have been visited to ensure acyclicity.

Also: in a test case, constraint Num a to Int.