get_bloq_call_graph#

Recursively build the bloq call graph and call totals.

See Bloq.call_graph() as a convenient way of calling this function.

bloq

The bloq to count sub-bloqs.

generalizer

If provided, run this function on each (sub)bloq to replace attributes that do not affect resource estimates with generic sympy symbols. If the function returns None, the bloq is omitted from the counts graph. If a sequence of generalizers is provided, each generalizer will be run in order.

ssa

a SympySymbolAllocator that will be passed to the Bloq.build_call_graph method. If your generalizer function closes over a SympySymbolAllocator, provide it here as well. Otherwise, we will create a new allocator.

keep

If this function evaluates to True for the current bloq, keep the bloq as a leaf node in the call graph instead of recursing into it.

max_depth

If provided, build a call graph with at most this many layers.

g

A directed graph where nodes are (generalized) bloqs and edge attribute ‘n’ reports the number of times successor bloq is called via its predecessor.

sigma

Call totals for “leaf” bloqs. We keep a bloq as a leaf in the call graph according to keep and max_depth (if provided) or if a bloq cannot be decomposed.