本文整理汇总了Python中halp.directed_hypergraph.DirectedHypergraph.get_hyperedge_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python DirectedHypergraph.get_hyperedge_attribute方法的具体用法?Python DirectedHypergraph.get_hyperedge_attribute怎么用?Python DirectedHypergraph.get_hyperedge_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类halp.directed_hypergraph.DirectedHypergraph
的用法示例。
在下文中一共展示了DirectedHypergraph.get_hyperedge_attribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_hyperedge_attribute
# 需要导入模块: from halp.directed_hypergraph import DirectedHypergraph [as 别名]
# 或者: from halp.directed_hypergraph.DirectedHypergraph import get_hyperedge_attribute [as 别名]
def test_get_hyperedge_attribute():
node_a = 'A'
node_b = 'B'
node_c = 'C'
node_d = 'D'
tail1 = set([node_a, node_b])
head1 = set([node_c, node_d])
frozen_tail1 = frozenset(tail1)
frozen_head1 = frozenset(head1)
tail2 = set([node_b, node_c])
head2 = set([node_d, node_a])
frozen_tail2 = frozenset(tail2)
frozen_head2 = frozenset(head2)
attrib = {'weight': 6, 'color': 'black'}
common_attrib = {'sink': False}
hyperedges = [(tail1, head1, attrib), (tail2, head2)]
H = DirectedHypergraph()
hyperedge_names = \
H.add_hyperedges(hyperedges, common_attrib, color='white')
assert H.get_hyperedge_attribute('e1', 'weight') == 6
assert H.get_hyperedge_attribute('e1', 'color') == 'black'
assert H.get_hyperedge_attribute('e1', 'sink') is False
# Try requesting an invalid hyperedge
try:
H.get_hyperedge_attribute('e5', 'weight')
assert False
except ValueError:
pass
except BaseException as e:
assert False, e
# Try requesting an invalid attribute
try:
H.get_hyperedge_attribute('e1', 'source')
assert False
except ValueError:
pass
except BaseException as e:
assert False, e