dag.py 文件源码

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

项目:SoS 作者: vatlab 项目源码 文件源码
def subgraph_from(self, targets):
        '''Trim DAG to keep only nodes that produce targets'''
        # first, find all nodes with targets
        subnodes = []
        for node in self.nodes():
            if not isinstance(node._output_targets, Undetermined) and any(x in node._output_targets for x in targets):
                subnodes.append(node)
        #
        ancestors = set()
        for node in subnodes:
            ancestors |= nx.ancestors(self, node)
        return SoS_DAG(nx.subgraph(self, subnodes + list(ancestors)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号