Ended with uva/topsort, added algo/minqueue