Exemplo n.º 1
0
def test_init_complete_then_add_edge():
    graph = PartialAncestralGraph(complete=True, variables=['A', 'B', 'C'])
    graph.add_edge('E o-> D')
    assert graph.has_edge('E o-> D')
    assert graph.has_edge('D <-o E')

    assert graph.has_edge('A o-o B')
    assert graph.has_edge('C o-o B')
    assert graph.has_edge('A o-o C')

    assert graph.has_edge('D o-o A') is False
Exemplo n.º 2
0
def test_init_complete_graph():
    graph = PartialAncestralGraph(complete=True, variables=['A', 'B', 'C'])

    assert graph.has_edge('A o-o B')
    assert graph.has_edge('C o-o B')
    assert graph.has_edge('A o-o C')

    assert set({'A', 'C'}) == graph.get_neighbors('B')
    assert set({'B', 'C'}) == graph.get_neighbors('A')

    assert Edge('A o-o B') in graph.get_edges()
    assert Edge('A o-o A') not in graph.get_edges()
    assert Edge('B o-o B') not in graph.get_edges()
Exemplo n.º 3
0
def test_add_edge():
    graph = PartialAncestralGraph()

    assert graph.has_edge('A o-o B') is False
    assert graph.has_edge('B o-o A') is False

    graph.add_edge('A o-o B')
    assert graph.has_edge('A o-o B') is True
    assert graph.has_edge('B o-o A') is True

    graph = PartialAncestralGraph()

    assert graph.has_edge('A --o B') is False
    assert graph.has_edge('B o-- A') is False
    graph.add_edge('A --o B')
    assert graph.has_edge('B o-- A') is True
    assert graph.has_edge('A --o B') is True

    graph = PartialAncestralGraph()

    assert graph.has_edge('A o-- B') is False
    assert graph.has_edge('B --o A') is False
    graph.add_edge('A o-- B')
    assert graph.has_edge('B --o A') is True
    assert graph.has_edge('A o-- B') is True

    graph = PartialAncestralGraph()

    assert graph.has_edge('A --- B') is False
    assert graph.has_edge('B --- A') is False
    graph.add_edge('A --- B')
    assert graph.has_edge('B --- A') is True
    assert graph.has_edge('A --- B') is True

    graph = PartialAncestralGraph()

    assert graph.has_edge('A o-> B') is False
    assert graph.has_edge('B <-o A') is False
    graph.add_edge('A o-> B')
    assert graph.has_edge('A o-> B') is True
    assert graph.has_edge('B <-o A') is True

    graph = PartialAncestralGraph()

    assert graph.has_edge('A <-> B') is False
    assert graph.has_edge('B <-> A') is False
    graph.add_edge('A <-> B')
    assert graph.has_edge('A <-> B') is True
    assert graph.has_edge('B <-> A') is True