本文整理汇总了Python中networkx.DiGraph.name方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.name方法的具体用法?Python DiGraph.name怎么用?Python DiGraph.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx.DiGraph
的用法示例。
在下文中一共展示了DiGraph.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_directed
# 需要导入模块: from networkx import DiGraph [as 别名]
# 或者: from networkx.DiGraph import name [as 别名]
def to_directed(self):
from networkx import DiGraph
G = DiGraph()
G.name = self.name
G.add_nodes_from(self.n)
G.add_edges_from(((u, v, deepcopy(data))
for u, nbrs in self.a
for v, data in nbrs.items()))
G.graph = deepcopy(self.data)
G._nodedata = deepcopy(self._nodedata)
G.node = G._nodedata # hack to pass test
return G
示例2: to_directed
# 需要导入模块: from networkx import DiGraph [as 别名]
# 或者: from networkx.DiGraph import name [as 别名]
def to_directed(self):
from networkx import DiGraph
G=DiGraph()
G.name=self.name
G.add_nodes_from(self)
G.add_edges_from( ((u,v,deepcopy(data))
for u,nbrs in self.adjacency_iter()
for v,data in nbrs.iteritems()) )
G.graph=deepcopy(self.graph)
G.node=deepcopy(self.node)
return G
示例3: _rename_nodes
# 需要导入模块: from networkx import DiGraph [as 别名]
# 或者: from networkx.DiGraph import name [as 别名]
def _rename_nodes(self, graph):
new_graph = DiGraph()
# print len(self._node_names)
for node in graph.nodes():
# Add all the nodes with the names given in the data set
new_node_name = self._node_names[node]
new_graph.add_node(new_node_name)
for edge in graph.edges():
# Add all the with the names given in the data set
new_source_node = self._node_names[ edge[0] ]
new_destination_node = self._node_names[ edge[1] ]
new_graph.add_edge(new_source_node, new_destination_node)
new_graph.name = self._network_name
return new_graph