当前位置: 首页>>代码示例>>Python>>正文


Python DirectedHypergraph.get_symmetric_image方法代码示例

本文整理汇总了Python中halp.directed_hypergraph.DirectedHypergraph.get_symmetric_image方法的典型用法代码示例。如果您正苦于以下问题:Python DirectedHypergraph.get_symmetric_image方法的具体用法?Python DirectedHypergraph.get_symmetric_image怎么用?Python DirectedHypergraph.get_symmetric_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在halp.directed_hypergraph.DirectedHypergraph的用法示例。


在下文中一共展示了DirectedHypergraph.get_symmetric_image方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_symmetric_image

# 需要导入模块: from halp.directed_hypergraph import DirectedHypergraph [as 别名]
# 或者: from halp.directed_hypergraph.DirectedHypergraph import get_symmetric_image [as 别名]
def test_get_symmetric_image():
    node_a = 'A'
    node_b = 'B'
    node_c = 'C'
    node_d = 'D'
    node_e = 'E'

    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)

    tail3 = set([node_d])
    head3 = set([node_e])
    frozen_tail3 = frozenset(tail3)
    frozen_head3 = frozenset(head3)

    hyperedges = [(tail1, head1), (tail2, head2), (tail3, head3)]

    H = DirectedHypergraph()
    hyperedge_names = H.add_hyperedges(hyperedges)

    sym_H = H.get_symmetric_image()

    sym_H._check_consistency()

    assert sym_H._node_attributes == H._node_attributes

    assert sym_H._hyperedge_attributes["e1"]["tail"] == head1
    assert sym_H._hyperedge_attributes["e1"]["head"] == tail1
    assert sym_H._hyperedge_attributes["e1"]["__frozen_tail"] == frozen_head1
    assert sym_H._hyperedge_attributes["e1"]["__frozen_head"] == frozen_tail1
    assert sym_H._hyperedge_attributes["e2"]["tail"] == head2
    assert sym_H._hyperedge_attributes["e2"]["head"] == tail2
    assert sym_H._hyperedge_attributes["e2"]["__frozen_tail"] == frozen_head2
    assert sym_H._hyperedge_attributes["e2"]["__frozen_head"] == frozen_tail2
    assert sym_H._hyperedge_attributes["e3"]["tail"] == head3
    assert sym_H._hyperedge_attributes["e3"]["head"] == tail3
    assert sym_H._hyperedge_attributes["e3"]["__frozen_tail"] == frozen_head3
    assert sym_H._hyperedge_attributes["e3"]["__frozen_head"] == frozen_tail3

    assert sym_H._forward_star[node_a] == set(["e2"])
    assert sym_H._forward_star[node_b] == set()
    assert sym_H._forward_star[node_c] == set(["e1"])
    assert sym_H._forward_star[node_d] == set(["e1", "e2"])
    assert sym_H._forward_star[node_e] == set(["e3"])

    assert sym_H._backward_star[node_a] == set(["e1"])
    assert sym_H._backward_star[node_b] == set(["e1", "e2"])
    assert sym_H._backward_star[node_c] == set(["e2"])
    assert sym_H._backward_star[node_d] == set(["e3"])
    assert sym_H._backward_star[node_e] == set()
开发者ID:Murali-group,项目名称:halp,代码行数:59,代码来源:test_directed_hypergraph.py


注:本文中的halp.directed_hypergraph.DirectedHypergraph.get_symmetric_image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。