diff --git a/.gitignore b/.gitignore index f1c6544..d77c715 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,6 @@ venv.bak/ # data files referencePathways/reactome/*.gOut + +# output files +*.sif \ No newline at end of file diff --git a/graph5_flow1_c1.0.sif b/graph5_flow1_c1.0.sif deleted file mode 100644 index 684842d..0000000 --- a/graph5_flow1_c1.0.sif +++ /dev/null @@ -1,2 +0,0 @@ -B A -C B diff --git a/graphs/graph5/edges.txt b/graphs/graph5/edges.txt index bb629d3..2ca040c 100644 --- a/graphs/graph5/edges.txt +++ b/graphs/graph5/edges.txt @@ -1,9 +1,12 @@ -A B 0.98 -B C 0.77 -A D 0.12 -C D 0.89 -C E 0.59 -C F 0.50 -F G 0.76 -G H 0.92 -G I 0.66 +A B 0.98 U +B C 0.77 U +A D 0.12 U +A D 0.12 D +C D 0.89 U +C E 0.59 U +A D 0.12 D +C F 0.50 U +F G 0.76 U +G H 0.92 U +G I 0.66 U +B C 0.77 U \ No newline at end of file diff --git a/graphs/graph_dir_col/edges.txt b/graphs/graph_dir_col/edges.txt deleted file mode 100644 index 3ac04d7..0000000 --- a/graphs/graph_dir_col/edges.txt +++ /dev/null @@ -1,9 +0,0 @@ -A B 0.98 U -B C 0.77 U -A D 0.12 D -C D 0.89 U -C E 0.59 U -C F 0.50 U -F G 0.76 U -G H 0.92 U -G I 0.66 U diff --git a/graphs/graph_dir_col/sources.txt b/graphs/graph_dir_col/sources.txt deleted file mode 100644 index 8c7e5a6..0000000 --- a/graphs/graph_dir_col/sources.txt +++ /dev/null @@ -1 +0,0 @@ -A \ No newline at end of file diff --git a/graphs/graph_dir_col/targets.txt b/graphs/graph_dir_col/targets.txt deleted file mode 100644 index 2c29ca5..0000000 --- a/graphs/graph_dir_col/targets.txt +++ /dev/null @@ -1,4 +0,0 @@ -C -D -H -I \ No newline at end of file diff --git a/minCostFlow.py b/minCostFlow.py index 5e2fe56..9f2b2ec 100644 --- a/minCostFlow.py +++ b/minCostFlow.py @@ -47,17 +47,19 @@ def construct_digraph(edges_file, cap): w = int((1-(float(tokens[2])))*100) d = tokens[3] - if d == "U": + # TODO: is it better to overwrite the edges or just to throw an error + if (node1, node2) in edges_dict: + raise KeyError(f"Failed to add the edge ({node1}, {node2}) with weight '{tokens[2]}' and directionality '{d}'. This edge conflicts with an existing '{edges_dict[(node1, node2)]}' edge in the graph.") + elif d == "U": edges_dict[(node1, node2)] = "U" edges_dict[(node2, node1)] = "U" G.add_arc_with_capacity_and_unit_cost(idDict[node1],idDict[node2], default_capacity, int(w)) G.add_arc_with_capacity_and_unit_cost(idDict[node2],idDict[node1], default_capacity, int(w)) - elif d == "D": edges_dict[(node1, node2)] = "D" G.add_arc_with_capacity_and_unit_cost(idDict[node1],idDict[node2], default_capacity, int(w)) else: - raise ValueError (f"d = {d}") + raise ValueError (f"Cannot add egdge: d = {d}") idDict["maxID"] = curID return G,idDict