I wrote up a program which counts the size of the 5 largest SCC's in a given graph. The number of nodes in the graph is 875714. Following is the basic DFS code I'm using in the problem. (Both functions are methods in a class)
def DFSloop(self):
exp = [False] * (self.size + 1)
for i in range(1,(self.size + 1)):
if exp[i] == False:
self.DFS(i, exp)
def DFS(self, s, exp):
exp[s] = True
for vertex in self.g[s]:
if exp[vertex] == False:
self.DFS(vertex, exp)
Basically DFS has to recurse a lot as number of nodes and edges is huge. It showed the following error even after setting the recursion limit to 10,000
RuntimeError: maximum recursion depth exceeded in cmp
Then upon increasing the limit to 100,000, it showed:
Segmentation fault: 11
And the system crashed. Any help in overcoming the situation?