symd.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:symd 作者: xym-tool 项目源码 文件源码
def prune_standalone_nodes():
    """
    Remove from the module dependency graph all modules that do not have any
    dependencies (i.e they neither import/include any modules nor are they
    imported/included by any modules)
    :return: the connected module dependency graph
    """
    ng = nx.DiGraph(G)
    for node_name in G.nodes_iter():
        ancestors = nx.ancestors(G, node_name)
        descendants = nx.descendants(G, node_name)
        if len(ancestors) == 0 and len(descendants) == 0:
            ng.remove_node(node_name)
    return ng
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号