From c2a7799951cfcafea130b4098238a0fa63ea3065 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Fri, 8 Sep 2023 19:10:42 +0200
Subject: [PATCH] Get `e_overestim` from graph property

Instead of reading it from standard input.
---
 Trajectories/Tests/segments_cost.graphml |  2 ++
 Trajectories/Tests/tests.json            | 12 ++++--------
 Trajectories/trajectories.py             |  4 +---
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/Trajectories/Tests/segments_cost.graphml b/Trajectories/Tests/segments_cost.graphml
index 228a56d0..85b6aed8 100644
--- a/Trajectories/Tests/segments_cost.graphml
+++ b/Trajectories/Tests/segments_cost.graphml
@@ -5,12 +5,14 @@
 
   <!-- property keys -->
   <key id="key0" for="edge" attr.name="cost_function" attr.type="float" />
+  <key id="key1" for="graph" attr.name="e_overestim" attr.type="int" />
   <key id="key3" for="node" attr.name="inst_eddies" attr.type="vector_int" />
   <key id="key6" for="node" attr.name="name" attr.type="string" />
 
   <graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">
 
    <!-- graph properties -->
+   <data key="key1">10</data>
 
    <!-- vertices -->
     <node id="n0">
diff --git a/Trajectories/Tests/tests.json b/Trajectories/Tests/tests.json
index f3c6120e..ddbe3827 100644
--- a/Trajectories/Tests/tests.json
+++ b/Trajectories/Tests/tests.json
@@ -74,16 +74,14 @@
 	"command": [
             "$src_dir/Trajectories/trajectories.py",
             "$tests_old_dir/Cost_functions/segments_cost_functions.graphml"
-	],
-	"input": "10"
+	]
     },
     "Greece_trajectories": {
 	"description": "A larger case than Trajectories.",
 	"command": [
             "$src_dir/Trajectories/trajectories.py",
             "$tests_old_dir/Greece_cost_function/segments_cost_functions.graphml"
-	],
-	"input": "7"
+	]
     },
     "Draw_segments":
     {
@@ -125,8 +123,7 @@
 	    "$src_dir/Trajectories/trajectories.py",
 	    "$src_dir/Trajectories/Tests/segments_cost.graphml"
 	],
-	"description": "A toy case of division followed by fusion.",
-	"input": "10"
+	"description": "A toy case of division followed by fusion."
     },
     "Test_order_edges":
     {
@@ -135,7 +132,6 @@
 	    "$src_dir/Trajectories/trajectories.py",
 	    "$src_dir/Trajectories/Tests/example_2.graphml"
 	],
-	"description": "A toy case to test the algorithm in trajectories.py, specifically to test the order in which edges are processed.",
-	"input": "10"
+	"description": "A toy case to test the algorithm in trajectories.py, specifically to test the order in which edges are processed."
     }
 }
diff --git a/Trajectories/trajectories.py b/Trajectories/trajectories.py
index de74e856..edd924ee 100755
--- a/Trajectories/trajectories.py
+++ b/Trajectories/trajectories.py
@@ -83,8 +83,6 @@ def assign_traj_edge(source, target, traj_prop, ind_traj, g, traj_segm,
 
 if len(sys.argv) != 2: sys.exit("Required argument: input-graph")
 g = graph_tool.load_graph(sys.argv[1])
-e_overestim = input("Enter e_overestim: ")
-e_overestim = int(e_overestim)
 
 traj_prop = g.new_vertex_property('int', val = - 1)
 # Trajectory index to which a segment belongs. - 1 means the segment
@@ -101,7 +99,7 @@ my_subgraphs = {}
 if "cost_function" in g.edge_properties:
     for v in g.vertices():
         date_index = report_graph.node_to_date_eddy(int(g.vp.name[v]),
-                                                    e_overestim,
+                                                    g.gp.e_overestim,
                                                     only_date = True)
 
         if date_index in my_subgraphs:
-- 
GitLab