Skip to content

Commit

Permalink
added link to optimal steiner tree solver
Browse files Browse the repository at this point in the history
  • Loading branch information
simulatedScience committed Jun 30, 2024
1 parent 9a778cc commit 19f5e3f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ttr_map_maker/task_editor_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def calculate_task_length(self, task: TTR_Task, include_bonus_points: bool = Tru
elif len(task.node_names) == 2:# or not include_bonus_points:
return nx.shortest_path_length(self.networkx_graph, task.node_names[0], task.node_names[-1], weight="length")
elif len(task.node_names) > 2 and not include_bonus_points:
# TODO: implement optimal Steiner-Tree solver: https://chatgpt.com/share/39b0e6c3-fd1f-4828-bc54-b70631aaf692
min_length_to_connect_nodes: int = nx.algorithms.approximation.steiner_tree(self.networkx_graph, task.node_names, weight="weight", method="mehlhorn").size("length")
return int(min_length_to_connect_nodes)
else: # return sum of all path lengths between all nodes assuming them to be ordered to achieve the shortest path
Expand Down

0 comments on commit 19f5e3f

Please sign in to comment.