Topo Sort to get edge script