Simple directed graph implementation for topological sorting
