Skip to content

Commit

Permalink
Split edge cost differently
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickOHara committed Apr 5, 2022
1 parent 4751e7a commit 734a980
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/test_converter/test_split_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def test_split_graph_from_properties():
G = split_graph_from_properties(properties)
for _, _, data in G.edges(data=True):
old_edge = data["old_edge"]
assert data["cost"] == float(properties[old_edge]["cost"]) / 2.0
assert data["cost"] == float(properties[old_edge]["cost"]) or data["cost"] == 0
5 changes: 2 additions & 3 deletions tspwplib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,8 @@ def split_edge_cost(
split_cost = {}
for edge, cost in edge_cost.items():
first_split, second_split = to_split[edge]
half_cost = float(cost) / 2.0
split_cost[first_split] = half_cost
split_cost[second_split] = half_cost
split_cost[first_split] = cost
split_cost[second_split] = 0
return split_cost


Expand Down

0 comments on commit 734a980

Please sign in to comment.