animate

Animate the graph of recursive functions calls

Node and Edge Coordinates


source

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


source

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

  1. max_node_length: the length of the longest node annotation text; used to determine the size of the node (in pixels)
  2. node_annotations: the text that appears in each node; this is set to be the input to the recursive function
  3. hovertext: 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

source

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

  1. edge_text: the text that appears along each edge; this is set to be edge_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

source

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


source

get_slider

 get_slider ()

Return the slider that allows the user to control the animation


source

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

source

get_play_pause_buttons

 get_play_pause_buttons ()

Return the play/pause buttons

References:

  1. Heavily inspired by Plotly animation tutorial

source

get_axis_settings

 get_axis_settings ()

Return the axis settings

Generate Animation


source

animate

 animate (history, nodes, func_name, DG, edge_to_label, display_args)