本文整理汇总了Python中network.Network.find_node方法的典型用法代码示例。如果您正苦于以下问题:Python Network.find_node方法的具体用法?Python Network.find_node怎么用?Python Network.find_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.find_node方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dont_lose_nodes
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import find_node [as 别名]
def test_dont_lose_nodes(self):
n1 = Node(1)
n2 = Node(2)
n1.add_arc(Arc(n2))
nw = Network([n1])
self.assertEqual(nw.find_node(2), n2)
n3 = Node(3)
n2.add_arc(Arc(n3))
self.assertEqual(nw.find_node(3), n3)
示例2: test_basic
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import find_node [as 别名]
def test_basic(self):
node = Node('one')
nw = Network([node])
self.assertEqual(nw.find_node('one'), node)
node = Node(('two', 2))
nw.add_node(node)
self.assertEqual(nw.find_node(('two', 2)), node)
three = Node('three')
arc = Arc(three, 1)
nw.find_node('one').add_arc(arc)
self.assertEqual(nw.find_node('three'), three)
示例3: create_non_zero_flow_network
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import find_node [as 别名]
def create_non_zero_flow_network(self, color):
if not self.is_colored_vbmap_problem():
raise ValueError("VbMapProblem instance is not a colored map problem")
network = Network()
za = self.get_active_vbucket_moves()[color]
for i, a in enumerate(self.prev_avb()[color]):
if a > 0:
node = Node(("prev_avb", i), a)
network.add_node(node)
for j, x in enumerate(za[i]):
if x > 0:
to_node = network.find_or_create_node(('avb', j))
node.add_arc(Arc(to_node, x))
avb = self.get_colored_avb()[color]
# print "avb: ", avb
x = self.get_colored_replication_map()[color]
# for i in range(len(x)):
# print "x[{0}]: ".format(i), x[i]
for i, a in enumerate(avb):
if a > 0:
node = network.find_or_create_node(("avb", i))
for j, y in enumerate(x[i]):
if y > 0:
to_node = network.find_or_create_node(('rvb', j))
node.add_arc(Arc(to_node, y))
zr = self.get_replica_vbucket_moves()[color]
for i, a in enumerate(self.prev_rvb()[color]):
if a > 0:
node = network.find_or_create_node(("prev_rvb", i))
node.set_source(-a)
for j in range(len(zr)):
y = zr[j][i]
if y > 0:
from_node = network.find_node(('rvb', j))
from_node.add_arc(Arc(node, y))
return network