animate
Animate the graph of recursive functions calls
Node and Edge Coordinates
get_node_and_edge_coordinates
get_node_and_edge_coordinates (DG)
Given a map of edges to labels, create a networkx
graph and use its layout function to return a list of x and y coordinates for placing nodes and edges on a 2D plot.
Type | Details | |
---|---|---|
DG | networkx graph of recursive function calls |
|
Returns | List | list of x and y coordinates for placing nodes and edges on 2D plot |
Text
get_node_text
get_node_text (nodes:Dict[int,recursion_visualizer.node.Node], func_name:str, display_args)
Return the text(s) to be displayed on each node. Specifically, return
max_node_length
: the length of the longest node annotation text; used to determine the size of the node (in pixels)node_annotations
: the text that appears in each node; this is set to be the input to the recursive functionhovertext
: the text that appears when the user hovers over a node in the graph; this is set to the input+output to the recursive function and the discovery+finish times of the recursive function.
Type | Details | |
---|---|---|
nodes | Dict | map of node ids to nodes |
func_name | str | name of the recursive function |
display_args | ||
Returns | List | text(s) to be displayed on each node |
get_edge_text
get_edge_text (node_x:List[int], node_y:List[int], edge_to_label:Dict[tuple,str])
Return the text(s) to be displayed on each edge. This is optional and by default will display an empty string along each edge. Specifically, return
edge_text
: the text that appears along each edge; this is set to beedge_label
, a keyword found in the decorated recursive function.
Type | Details | |
---|---|---|
node_x | List | x coordinates of nodes |
node_y | List | y coordinates of nodes |
edge_to_label | Dict | map of edges to labels (edge is a tuple of two node ids) |
Returns | List | text(s) to be displayed on each edge |
get_link_annotation
get_link_annotation ()
Return the (formatted) text that links to this library’s GitHub repo.
get_title
get_title (nodes:Dict[int,recursion_visualizer.node.Node], func_name:str)
Return the (formatted) title of the graph
Type | Details | |
---|---|---|
nodes | Dict | map of node ids to nodes |
func_name | str | name of the recursive function |
Returns | str | title of the graph |
Graphics
get_slider
get_slider ()
Return the slider that allows the user to control the animation
update_slider
update_slider (slider:dict, time:int)
Update the slider with the current time
Type | Details | |
---|---|---|
slider | dict | slider that allows the user to control the animation |
time | int | current time |
Returns | dict | updated slider |
get_axis_settings
get_axis_settings ()
Return the axis settings
Generate Animation
animate
animate (history, nodes, func_name, DG, edge_to_label, display_args)