本文整理汇总了Python中networkx.classes.digraph.DiGraph.node[4]['r']方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.node[4]['r']方法的具体用法?Python DiGraph.node[4]['r']怎么用?Python DiGraph.node[4]['r']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx.classes.digraph.DiGraph
的用法示例。
在下文中一共展示了DiGraph.node[4]['r']方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_example_2
# 需要导入模块: from networkx.classes.digraph import DiGraph [as 别名]
# 或者: from networkx.classes.digraph.DiGraph import node[4]['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[4]['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
示例3: get_example_5
# 需要导入模块: from networkx.classes.digraph import DiGraph [as 别名]
# 或者: from networkx.classes.digraph.DiGraph import node[4]['r'] [as 别名]
def get_example_5():
g = DiGraph()
g.add_edges_from([(0, 1), (0, 2), (1, 3), (1, 4),
(2, 4), (2, 5), (2, 6)])
for s, t in g.edges():
g[s][t]['c'] = 1
g[1][4]['c'] = 0
g[2][4]['c'] = 0
g[2][6]['c'] = 3
for n in g.nodes():
g.node[n]['r'] = 1
g.node[3]['r'] = 10
g.node[4]['r'] = 100
g.node[5]['r'] = 11
U = [10]
# sub-optimal answer actually
expected_edge_set = [[(0, 2), (2, 4), (2, 5), (2, 6)]]
return (g, U, expected_edge_set)
示例4: get_example_6
# 需要导入模块: from networkx.classes.digraph import DiGraph [as 别名]
# 或者: from networkx.classes.digraph.DiGraph import node[4]['r'] [as 别名]
def get_example_6():
# IN-OPTIMAL CASE
g = DiGraph()
g.add_edges_from([(0, 1), (0, 2), (1, 3),
(1, 4), (2, 4), (2, 5)])
for s, t in g.edges():
g[s][t]['c'] = 0
g[1][3]['c'] = 4
g[1][4]['c'] = 4
g[2][4]['c'] = 2
g[2][5]['c'] = 1
for n in g.nodes():
g.node[n]['r'] = 0
g.node[3]['r'] = 1
g.node[4]['r'] = 100
g.node[5]['r'] = 1
U = [7]
# sub-optimal answer actually
expected_edge_set = [[(0, 2), (2, 4), (2, 5)]]
return (g, U, expected_edge_set)