Imagine you have a folder with many python modules and each of them contains functions. I would like to visualize a graph with vertices = function names. I want to define the edges as follows: if function F1 calls F2 then the vertex of F1 is connected to F2 with a directed edge.
Minimal example with a single module:
# --- module.py ---
def F1():
pass
def F2():
F1()
def F3():
F1()
def F4():
F2()
The desired output would be a graph with vertices: V = {F1, F2, F3, F4}
and edges E = {F2->F1, F3->F1, F4->F2}
.
Is there a convenient library to do this? Otherwise I imagine I can covert the module to string, identify the functions and find internal calls with some regex expressions.
Thanks