Beispiel #1
0
def test_transitive_closure():
    edges = graphs.graph({
        "a": {},
        "b": {"c", "d"},
        "c": set(),
        "d": {"e"},
        "e": set()
    })
    assert graphs.transitive_closure(edges) == {
        "a": set(),
        "b": {"c", "d", "e"},
        "c": set(),
        "d": {"e"},
        "e": set(),
    }
Beispiel #2
0
def test_toposort():
    edges = graphs.graph({'a': set(['b', 'c']), 'b': ('c',)})
    assert graphs.toposort(edges) == ['a', 'b', 'c']
Beispiel #3
0
def test_reversedict():
    edges = graphs.graph({'a': set(['b', 'c'])})
    r_edges = graphs.reverse_edges(edges)
    assert r_edges == {'b': ('a',), 'c': ('a',)}
Beispiel #4
0
def test_add_edges():
    edges = graphs.graph({'a': set(['b', 'c'])})
    graphs.add_edges(edges, [('a', 'd'), ('b', 'c')])
    assert edges == {'a': set(['b', 'c', 'd']), 'b': set(['c'])}
Beispiel #5
0
def test_toposort():
    edges = graphs.graph({'a': {'b', 'c'}, 'b': ('c', )})
    assert graphs.toposort(edges) == ['a', 'b', 'c']
Beispiel #6
0
def test_reversedict():
    edges = graphs.graph({'a': {'b', 'c'}})
    r_edges = graphs.reverse_edges(edges)
    assert r_edges == {'b': ('a', ), 'c': ('a', )}
Beispiel #7
0
def test_add_edges():
    edges = graphs.graph({'a': {'b', 'c'}})
    graphs.add_edges(edges, [('a', 'd'), ('b', 'c')])
    assert edges == {'a': {'b', 'c', 'd'}, 'b': {'c'}}
Beispiel #8
0
def test_add_edges():
    edges = graphs.graph({'a': set(['b', 'c'])})
    graphs.add_edges(edges, [('a', 'd'), ('b', 'c')])
    assert edges == {'a': set(['b', 'c', 'd']), 'b': set(['c'])}
Beispiel #9
0
def test_toposort():
    edges = graphs.graph({"a": {"b", "c"}, "b": {"c"}, "c": set()})
    assert graphs.toposort(edges) == ["a", "b", "c"]
Beispiel #10
0
def test_add_edges():
    edges = graphs.graph({"a": {"b", "c"}})
    graphs.add_edges(edges, [("a", "d"), ("b", "c")])
    assert edges == {"a": {"b", "c", "d"}, "b": {"c"}}
Beispiel #11
0
def test_reversedict():
    edges = graphs.graph({"a": {"b", "c"}, "b": set(), "c": set()})
    r_edges = graphs.reverse_edges(edges)
    assert r_edges == {"a": set(), "b": {"a"}, "c": {"a"}}
Beispiel #12
0
def test_toposort():
    edges = graphs.graph({'a': {'b', 'c'}, 'b': {'c'}, 'c': set()})
    assert graphs.toposort(edges) == ['a', 'b', 'c']
Beispiel #13
0
def test_reversedict():
    edges = graphs.graph({'a': {'b', 'c'}, 'b': set(), 'c': set()})
    r_edges = graphs.reverse_edges(edges)
    assert r_edges == {'a': set(), 'b': {'a'}, 'c': {'a'}}
Beispiel #14
0
def test_add_edges():
    edges = graphs.graph({'a': {'b', 'c'}})
    graphs.add_edges(edges, [('a', 'd'), ('b', 'c')])
    assert edges == {'a': {'b', 'c', 'd'}, 'b': {'c'}}
Beispiel #15
0
def test_transitive_closure():
    edges = graphs.graph(
        {'a': {}, 'b': {'c', 'd'}, 'c': set(), 'd': {'e', }, 'e': set()})
    assert graphs.transitive_closure(edges) == {
        'a': set(), 'b': {'c', 'd', 'e'}, 'c': set(), 'd': {'e'}, 'e': set()}