Python networkx 模块,compose() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用networkx.compose()

项目:pyhiro    作者:wanweiwei07    | 项目源码 | 文件源码
def __addEnds(self, obj0SRotmat4, obj1SRotmat4):
        """
        add the two ends to the graph

        :param obj0SRotmat4:
        :param obj1SRotmat4:
        :return:
        """

        self.regghalf[0].deleteEnd()
        self.regghalf[1].deleteEnd()
        self.regghalf[0].addEnd(obj0SRotmat4)
        self.regghalf[1].addEnd(obj1SRotmat4)
        self.regg = nx.compose(self.regghalf[0].graphtpp.regg, self.regghalf[1].graphtpp.regg)
        self.__addAssNodes(armname = 'rgt')
        self.__addAssNodes(armname = 'lft')
        self.__bridgeGraph()
项目:skymod    作者:DelusionalLogic    | 项目源码 | 文件源码
def from_depends(subtrees):
        G = nx.DiGraph()
        root = RootNode()
        for subG in subtrees:
            self.G = nx.compose(G, subG.G)
            self.G.add_edge(root, subG.root)
        return InstalledGraph(G, root)
项目:conda-concourse-ci    作者:conda    | 项目源码 | 文件源码
def collect_tasks(path, folders, matrix_base_dir, channels=None, steps=0, test=False,
                  max_downstream=5, variant_config_files=None):
    # runs = ['test']
    # not testing means build and test
    # if not test:
    #     runs.insert(0, 'build')
    runs = ['build']

    task_graph = nx.DiGraph()
    config = conda_build.api.Config()
    for run in runs:
        platforms = parse_platforms(matrix_base_dir, run)
        # loop over platforms here because each platform may have different dependencies
        # each platform will be submitted with a different label
        for platform in platforms:
            index_key = '-'.join([platform['platform'], str(platform['arch'])])
            config.channel_urls = channels or []
            config.variant_config_files = variant_config_files or []
            conda_resolve = Resolve(get_build_index(subdir=index_key,
                                                    bldpkgs_dir=config.bldpkgs_dir)[0])
            # this graph is potentially different for platform and for build or test mode ("run")
            g = construct_graph(path, worker=platform, folders=folders, run=run,
                                matrix_base_dir=matrix_base_dir, conda_resolve=conda_resolve,
                                config=config)
            # Apply the build label to any nodes that need (re)building or testing
            expand_run(g, conda_resolve=conda_resolve, worker=platform, run=run,
                       steps=steps, max_downstream=max_downstream, recipes_dir=path,
                       matrix_base_dir=matrix_base_dir)
            # merge this graph with the main one
            task_graph = nx.compose(task_graph, g)
    return task_graph
项目:sanskrit_parser    作者:kmadathil    | 项目源码 | 文件源码
def appendToNode(self, t, rdag):
        """ append rdag to self, adding edges from a given node to rdag's roots 

            Params:
                t (SanskritObject)      : Node to append to
             rdag (SanskritLexicalGraph): Graph to append to node
        """
        # t is in our graph
        assert t in self.G
        self.G = nx.compose(self.G, rdag.G)
        for r in rdag.roots:
            self.G.add_edge(t, r)
项目:pythia    作者:elazarg    | 项目源码 | 文件源码
def copy_to_bidirectional(g:nx.DiGraph, weight='weight'):
    return nx.compose(g, reverse_weights(g, weight=weight))