Skip to content

Commit

Permalink
new idea for duplicate edges
Browse files Browse the repository at this point in the history
  • Loading branch information
ntalluri committed Jan 2, 2024
1 parent 26cb3b1 commit d16a070
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ venv.bak/

# data files
referencePathways/reactome/*.gOut

# output files
*.sif
2 changes: 0 additions & 2 deletions graph5_flow1_c1.0.sif

This file was deleted.

21 changes: 12 additions & 9 deletions graphs/graph5/edges.txt
Original file line number Diff line number Diff line change
@@ -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
9 changes: 0 additions & 9 deletions graphs/graph_dir_col/edges.txt

This file was deleted.

1 change: 0 additions & 1 deletion graphs/graph_dir_col/sources.txt

This file was deleted.

4 changes: 0 additions & 4 deletions graphs/graph_dir_col/targets.txt

This file was deleted.

8 changes: 5 additions & 3 deletions minCostFlow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d16a070

Please sign in to comment.