scala implementation of the Tarjan SCC algorithm