def scc(graph):
order = []<EOL>vis = {vertex: False for vertex in graph}<EOL>graph_transposed = {vertex: [] for vertex in graph}<EOL>for (v, neighbours) in graph.iteritems():<EOL><INDENT>for u in neighbours:<EOL><INDENT>add_edge(graph_transposed, u, v)<EOL><DEDENT><DEDENT>for v in graph:<EOL><INDENT>if not vis[v]:<EOL><INDENT>dfs_transposed(v, graph_transposed, order, vis)<EOL><DEDENT><DEDENT>vis = {vertex: False for vertex in graph}<EOL>vertex_scc = {}<EOL>current_comp = <NUM_LIT:0><EOL>for v in reversed(order):<EOL><INDENT>if not vis[v]:<EOL><INDENT>dfs(v, current_comp, vertex_scc, graph, vis)<EOL>current_comp += <NUM_LIT:1><EOL><DEDENT><DEDENT>return vertex_scc<EOL>
Computes the strongly connected components of a graph