Begin topological sort. Added edge classification.