def update_stackdepth(cfg):
'''The stack depth is supposed to be independent of path.
So dijkstra on the undirected graph suffices (and maybe too strong. we don't need minimality)
The `undirected` part is just because we want to work
with unreachable code too.
'''
bidi = gu.copy_to_bidirectional(cfg, weight='stack_effect')
depths = nx.single_source_dijkstra_path_length(bidi, source=0, weight='stack_effect')
nx.set_node_attributes(cfg, 'stack_depth', depths)
return cfg
评论列表
文章目录