From dab0a3e80edcb901929324965e8cb46589159ae6 Mon Sep 17 00:00:00 2001 From: ntalluri Date: Tue, 23 Jan 2024 14:11:37 -0600 Subject: [PATCH] cleaned up code and added correct_outputs.txt for test graphs --- graphs/correct_outputs.txt | 53 ++++++++++++++++++++++++++++++++++++++ graphs/graph12/edges.txt | 4 +++ graphs/graph12/sources.txt | 1 + graphs/graph12/targets.txt | 1 + graphs/graph13/edges.txt | 4 +++ graphs/graph13/sources.txt | 1 + graphs/graph13/targets.txt | 1 + test_minCostFlow.py | 2 +- tests/correct_outputs.txt | 31 ++++++++++++++++++++++ 9 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 graphs/graph12/edges.txt create mode 100644 graphs/graph12/sources.txt create mode 100644 graphs/graph12/targets.txt create mode 100644 graphs/graph13/edges.txt create mode 100644 graphs/graph13/sources.txt create mode 100644 graphs/graph13/targets.txt diff --git a/graphs/correct_outputs.txt b/graphs/correct_outputs.txt index e69de29..7bd3a5b 100644 --- a/graphs/correct_outputs.txt +++ b/graphs/correct_outputs.txt @@ -0,0 +1,53 @@ +The graphs series of graphs are used to check the code's correctness. Except for internal tiebreaking by the solver, each result is deterministic. + +graph1: +A B D +B D D + +graph2: +A B D +B D D + +graph3: deals with tiebreaking +A C D +C D D + +graph4: +A B D +B D D + +graph5: +A B U +B D U + +graph6: +A B U +B D U + +graph7: deals with tiebreaking +A B U +B D U + +graph8: +A B U +B D U + +graph9: +A B D +B D U + +graph10: +A B D +B D D + +graph11: +A B U +B D U + +graph12: +A B D +B D D + +graph13: +A B U +B D U diff --git a/graphs/graph12/edges.txt b/graphs/graph12/edges.txt new file mode 100644 index 0000000..828be53 --- /dev/null +++ b/graphs/graph12/edges.txt @@ -0,0 +1,4 @@ +A B 0.9 D +A C 0.1 D +B D 0.8 D +C D 0.2 D diff --git a/graphs/graph12/sources.txt b/graphs/graph12/sources.txt new file mode 100644 index 0000000..8c7e5a6 --- /dev/null +++ b/graphs/graph12/sources.txt @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/graphs/graph12/targets.txt b/graphs/graph12/targets.txt new file mode 100644 index 0000000..02358d2 --- /dev/null +++ b/graphs/graph12/targets.txt @@ -0,0 +1 @@ +D \ No newline at end of file diff --git a/graphs/graph13/edges.txt b/graphs/graph13/edges.txt new file mode 100644 index 0000000..5b5ce23 --- /dev/null +++ b/graphs/graph13/edges.txt @@ -0,0 +1,4 @@ +A B 0.9 U +A C 0.1 U +B D 0.8 U +C D 0.2 U diff --git a/graphs/graph13/sources.txt b/graphs/graph13/sources.txt new file mode 100644 index 0000000..8c7e5a6 --- /dev/null +++ b/graphs/graph13/sources.txt @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/graphs/graph13/targets.txt b/graphs/graph13/targets.txt new file mode 100644 index 0000000..02358d2 --- /dev/null +++ b/graphs/graph13/targets.txt @@ -0,0 +1 @@ +D \ No newline at end of file diff --git a/test_minCostFlow.py b/test_minCostFlow.py index 1482d59..77b1382 100644 --- a/test_minCostFlow.py +++ b/test_minCostFlow.py @@ -22,7 +22,7 @@ print("\ntesting code correctness") -for i in range (1,12): +for i in range (1,14): print("graph: ",i) args = [ "--edges_file", f"graphs/graph{i}/edges.txt", diff --git a/tests/correct_outputs.txt b/tests/correct_outputs.txt index e69de29..6ac896b 100644 --- a/tests/correct_outputs.txt +++ b/tests/correct_outputs.txt @@ -0,0 +1,31 @@ +The tests series of graphs are used to verify whether the code is executing appropriately depending on distinct edge cases. + +test 1: check if unique directed edges are added to directed_dict +Output: +A B D +B C D + +test2: check if higher edge weight is selected for the same directed edge from the input +Output: +A B D +B D D + +test3: If a directed edge is present in the input and an undirected edge from that edge already exists, the directed edge is prioritized and added to directed_dict and the undirected edge is deleted from undirected_dict. +A C D +C D D + +test4: check if unique undirected edges are added to undirected_dict +A B D +B D D + +test5: check that an undirected edge is not added if a directed edge of that edge already exists +A B U +B D U + +test6: check if higher edge weight is selected for the same undirected edge from the input +A B U +B D U + +test7: check that code still runs and outputs an error message with an empty edges.txt +A B U +B D U