def test_DAG_get_v_structures(test_dag, reversed_dag, partial_dag): dag = test_dag assert partial_dag.get_v_structures() == {("C", "B", "D")} assert dag.get_v_structures() == set() assert dag.get_v_structures(True) == {("C", "B", "D")} assert reversed_dag.get_v_structures(True) == {("B", "D", "C")} # Test node order doesn't change V-structure tuple order other_dag = DAG() other_dag.add_vertices(list("DCBA")) other_dag.add_edges([("C", "B"), ("D", "B"), ("D", "C")]) assert other_dag.get_v_structures(True) == dag.get_v_structures(True)
def test_compare(temp_out, test_dag): img_path = temp_out / 'comparison.png' dag2 = DAG() dag2.add_vertices(list("ABCD")) comparison_1 = test_dag.compare(dag2) assert comparison_1.es['color'] == ['red'] * 3 assert comparison_1.es['style'] == ['dashed'] * 3 comparison_2 = dag2.compare(test_dag) assert comparison_2.es['color'] == ['blue'] * 3 assert comparison_2.es['style'] == ['solid'] * 3 comparison_1.plot(img_path) assert img_path.exists()