def test_transitive_reduction_no_reduction(): dag = DAG() dag.from_dict({'a': ['b', 'c'], 'b': ['d'], 'c': ['d'], 'd': []}) dag.transitive_reduction() assert dag.graph == { 'a': set(['b', 'c']), 'b': set('d'), 'c': set('d'), 'd': set() }
def test_transitive_reduction_no_reduction(): dag = DAG() dag.from_dict({'a': ['b', 'c'], 'b': ['d'], 'c': ['d'], 'd': []}) dag.transitive_reduction() assert dag.graph == {'a': set(['b', 'c']), 'b': set('d'), 'c': set('d'), 'd': set()}
def test_transitive_deep_reduction(): dag = DAG() # https://en.wikipedia.org/wiki/Transitive_reduction#/media/File:Tred-G.svg dag.from_dict({ 'a': ['b', 'd'], 'b': ['c'], 'c': ['d'], 'd': [], }) dag.transitive_reduction() # https://en.wikipedia.org/wiki/Transitive_reduction#/media/File:Tred-Gprime.svg assert dag.graph == {'a': set('b'), 'b': set('c'), 'c': set('d'), 'd': set()}