def _remove_unreachable_nodes(graph):
"""Remove all data structures that are not reachable
from modules or from stacks.
"""
removed = 0
for node in graph.nodes()[:]:
# check if reachable from globals
for root in graph.root_nodes:
if nx.has_path(graph, root, node):
break
else:
graph.remove_node(node)
removed += 1
return removed
评论列表
文章目录