1

Prompt

Generate a call graph for the 'process_payment' function, showing all
usages up to 3 levels deep

You can adjust the depth and add specific conditions to refine your visualization.

2

Review

The assistant will provide a codemod using NetworkX to create the function usage call graph. Here’s an example of what the code might look like:

# Create a directed graph
G = nx.DiGraph()

symbol = codebase.get_symbol('AbstractBillQuery')

# Add the main symbol as a node
G.add_node(symbol, color='red')

def add_usages_to_graph(current_symbol, current_depth, max_depth):
    if current_depth > max_depth:
        return
    # Iterate over all usages of the current symbol
    for usage in current_symbol.get_usages():
        G.add_node(usage.usage_symbol)
        G.add_edge(current_symbol, usage.usage_symbol)
        
        add_usages_to_graph(usage.usage_symbol, current_depth + 1, max_depth)

N = 5
add_usages_to_graph(symbol, 1, N)

codebase.visualize(G)
3

Interact

Hit Run and view the graph in the Output Tab. For more advanced customization options, check out our customize page.