I am implementing Depth-First Search algorithm to get strongly connected components of a graph having a very large number of nodes (upwards of 800,000).
When running, I get the following error:
RecursionError: maximum recursion depth exceeded in comparison
To solve this, I used help of the sys.setrecursionlimit(numNodes)
function.
When doing this, the IDLE begins to execute the code, but then restarts automatically without giving any output.
Based on a quick web search (for example), I think its because IDLE exceeded the memory limit when recursing through so many nodes.
For numNodes = 20000, sys.setrecursionlimit(3000)
does the trick
For numNodes = 40000, sys.setrecursionlimit(5000)
does the trick
For numNodes = 80000, sys.setrecursionlimit(5000)
restarts the IDLE. (NOTE here, it doesn't show RecursionError, but restarts the IDLE only)
DOUBT : What is the maximum value of the limit
for sys.setrecursionlimit(limit)
that I can set for my platform?
UPDATE : Other, similar questions on stack overflow ask how to change the value or what is maximum recursion depth. I need to understand what the maximum possible value of the "limit" is. sys.getrecursionlimit()
would give me whatever "limit" has been currently set.