Resolving dependencies in a directed acyclic graph with a topological sort