unit analysis with topological sort