Skip to content

Instantly share code, notes, and snippets.

View donalatorre's full-sized avatar

Adán López Alatorre donalatorre

  • Monterrey, Nuevo León, México
View GitHub Profile
@nhocki
nhocki / tarjan.cc
Created February 24, 2015 01:57
Tarjan Algorithm in C++
/* Complexity: O(E + V)
Tarjan's algorithm for finding strongly connected
components.
*d[i] = Discovery time of node i. (Initialize to -1)
*low[i] = Lowest discovery time reachable from node
i. (Doesn't need to be initialized)
*scc[i] = Strongly connected component of node i. (Doesn't
need to be initialized)
*s = Stack used by the algorithm (Initialize to an empty