本文整理汇总了Python中networkx.classes.digraph.DiGraph.node[1]['r']方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.node[1]['r']方法的具体用法?Python DiGraph.node[1]['r']怎么用?Python DiGraph.node[1]['r']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx.classes.digraph.DiGraph
的用法示例。
在下文中一共展示了DiGraph.node[1]['r']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_example_2
# 需要导入模块: from networkx.classes.digraph import DiGraph [as 别名]
# 或者: from networkx.classes.digraph.DiGraph import node[1]['r'] [as 别名]
def get_example_2():
# input
g = DiGraph()
g.add_edges_from([[1, 2], [1, 3], [2, 4], [3, 4]])
g.node[1]['r'] = 1
g.node[2]['r'] = 1
g.node[3]['r'] = 1.5
g.node[4]['r'] = 1
g[1][2]['c'] = 0.021
g[1][3]['c'] = 0.011
g[2][4]['c'] = 0.009
g[3][4]['c'] = 0.03
U = [float(i) / 100 for i in xrange(6)] # 0...5
# expected value
expected_edge_list = [
[],
[(1, 3)],
[(1, 3)],
[(1, 2), (1, 3)],
[(1, 2), (1, 3), (2, 4)],
[(1, 2), (1, 3), (2, 4)]
]
return (g, U, expected_edge_list)
示例2: get_example_1
# 需要导入模块: from networkx.classes.digraph import DiGraph [as 别名]
# 或者: from networkx.classes.digraph.DiGraph import node[1]['r'] [as 别名]
def get_example_1():
# input
g = DiGraph()
g.add_edges_from([[1, 2], [1, 3], [2, 4], [3, 4]])
g.node[1]['r'] = 1
g.node[2]['r'] = 1
g.node[3]['r'] = 1.5
g.node[4]['r'] = 1
g[1][2]['c'] = 2
g[1][3]['c'] = 1
g[2][4]['c'] = 1
g[3][4]['c'] = 3
U = range(6) # 0...5
expected_edge_list = [
[],
[(1, 3)],
[(1, 3)], # DiGraph([(1, 2)])
[(1, 2), (1, 3)],
[(1, 2), (1, 3), (2, 4)],
[(1, 2), (1, 3), (2, 4)]
]
return g, U, expected_edge_list