我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用networkx.dfs_tree()。
def dfs_postorder(self, root): G = nx.Graph(self.E) tree_graph = nx.dfs_tree(G,root) clique_ordering = list(nx.dfs_postorder_nodes(tree_graph,root)) return clique_ordering
def main(): func_list = parse.parse(open(sys.argv[1]).read()) G = foo(func_list) #G = callgraph(func_list) nx.write_dot(G,"G.dot") #H = nx.dfs_tree(G,'solver') #nx.write_dot(H,"H.dot") #print nx.topological_sort(H)
def _trim_subtree(self, tree, root): """Trims off and returns a subtree rooted at root. Updates all necessary internal state. :param tree: :type tree: nx.DiGraph :param root: :return: subtree rooted at root """ subtree = nx.dfs_tree(tree, root) self._update_bookkeeping(subtree, root) tree.remove_nodes_from(subtree.nodes()) return subtree