funkelab / motile

Multi-Object Tracker using Integer Linear Equations
https://funkelab.github.io/motile/
MIT License
27 stars 5 forks source link

Selected Subgraph #93

Closed lmanan closed 7 months ago

lmanan commented 7 months ago

I would update the code for obtaining a subgraph here:

from

for node_id, node in self.graph.nodes.items():
    if solution[node_selected[node_id]]:
        selected_graph.add_node(node_id, node)

for edge_id, edge in self.graph.edges.items():
    if solution[edge_selected[edge_id]]:
        selected_graph.add_edge(edge_id, edge)

to become,

for node_id, node in self.graph.nodes.items():
    if solution[node_selected[node_id]] > 0.5:
        selected_graph.add_node(node_id, node)

for edge_id, edge in self.graph.edges.items():
    if solution[edge_selected[edge_id]] > 0.5:
        selected_graph.add_edge(edge_id, edge)

Since the selected subgraph at times can skip a few nodes and edges if the solution indicator value on them is not exactly 1 but is 1.0000002etc.

tlambert03 commented 7 months ago

that would be just fine. could you make a PR?