Understanding Call Graph Traversal
At the heart of call graph traversal is the .function_calls property, which returns information about all function calls made within a function:Building a Call Graph
Here’s how to build a directed graph of function calls using NetworkX:Filtering and Visualization
You can filter the graph to show only relevant paths and visualize the results:Advanced Usage
Example: Finding Dead Code
You can use call graph analysis to find unused functions:Example: Analyzing Call Chains
Find the longest call chain in your codebase:The
.function_calls property is optimized for performance and uses Codegen’s internal graph structure to quickly traverse relationships. It’s much faster than parsing the code repeatedly.