compute finishing times for all vertices of G
group = 0
for each vertex u ∈ GT sorted by finishing time from largest to smallest
unless u has been visited
group = group + 1
DFS(GT,u)
u.visited = true
u.g = group
for each neighbor v of u sorted by finishing time from largest to smallest
unless v has been visited
DFS(G,v)