node
Each node represents a single recursive function call. Together, a graph of these nodes show which functions recursively call which other functions. This can be very helpful in developing an intutive understanding of each recursive call.
Other functions will thus build upon the Node class to create the animated graph of recursive function calls.
Node
Node (id_:int=None, input:tuple=None, output:<built-infunctionany>=None, depth:int=None, discovered:int=None, finish:int=None)
A node
| Type | Default | Details | |
|---|---|---|---|
| id_ | int | None | a unique id for the node |
| input | tuple | None | the input to the function represented by the node |
| output | any | None | the output of the function represented by the node |
| depth | int | None | the depth of the node in the graph (starting at 0) |
| discovered | int | None | the time the node was first discovered in the graph traversal |
| finish | int | None | the time the node (and its descendants) were finished being explored in the graph traversal |
This class records standard information about nodes in a graph: id, depth, discovered, and finish. However, in recursion-visualizer, each node represents a call to a recursive function so we store additional values: input and output which represent the input and output to the recursive function.
Time
The discovered time and finish time do not refer to the runtime or literal time of day. Instead this time is a way to record helpful information about the graph traversal. This time begins at zero and is incremented by one when a node is first discovered or when it (and its descandents) are completly finished being explored. In the context of storing recursive calls, discovered is when the recursive call is first made and its execution begins. finished is when the recursive call (and its subsequent functions calls) have all finished executing.