From 99d5a5a7a61213352507492f58e17063b28b146b Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 11 Oct 2023 22:53:38 +0200 Subject: [PATCH] Do not call `topology.shortest_path` This looked good but was much longer. For example, for `Global_1993_2023/Graph_anti`, this commit reduces elapsed time approximately from 24 mn to 2 mn. --- Trajectories/trajectories.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Trajectories/trajectories.py b/Trajectories/trajectories.py index 1233d805..d9ba1987 100755 --- a/Trajectories/trajectories.py +++ b/Trajectories/trajectories.py @@ -108,9 +108,13 @@ for n in topology.topological_sort(g): if date_merging - date_splitting <= 6: # We have a phantom pattern. Get the vertex on the # side of the shortest path: - v_short = topology.shortest_path( - g, n1, n, weights = g.ep.cost_function, - dag = True)[0][1] + if g.ep.cost_function[(n1, pred[0])] \ + + g.ep.cost_function[(pred[0], n)] \ + < g.ep.cost_function[(n1, pred[1])] \ + + g.ep.cost_function[(pred[1], n)]: + v_short = pred[0] + else: + v_short = pred[1] if traj_prop[v_short] != traj_prop[n1]: # Correct the trajectories that were assigned -- GitLab