From 754ade377099fe4b00dcbf6c1341280a638c245e Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Tue, 28 Jun 2022 23:56:31 +0200 Subject: [PATCH] Do not make trajectory an internal property No need for this property to be internal. --- trajectories.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/trajectories.py b/trajectories.py index 21c09ac2..d1e49597 100755 --- a/trajectories.py +++ b/trajectories.py @@ -3,7 +3,7 @@ """A script that loads a segmented cf graph in the gt format, iterates on all of the edges and cost functions and generates the trajectories as done in MATLAB. Segments (nodes) have a new vertex property called -"traj" that holds the trajectory ID that that segment belongs to. The +"traj_prop" that holds the trajectory ID that that segment belongs to. The output is either an expanded JSON file and/or an edgelist file with all of the trajectories. @@ -26,17 +26,17 @@ class Visitor(search.BFSVisitor): self.trajectories = {} def discover_vertex(self, u): - if g.vp.traj[u] not in self.trajectories: - self.trajectories[g.vp.traj[u]] = [g.vp.name[u]] + if traj_prop[u] not in self.trajectories: + self.trajectories[traj_prop[u]] = [g.vp.name[u]] else: - self.trajectories[g.vp.traj[u]].append(g.vp.name[u]) + self.trajectories[traj_prop[u]].append(g.vp.name[u]) g = graph_tool.load_graph(sys.argv[1]) -g.vp['traj'] = g.new_vp('int') +traj_prop = g.new_vp('int') # Assign the new vertex property: for node in g.vertices(): - g.vp.traj[node] = g.vp.name[node] + traj_prop[node] = g.vp.name[node] print('Setting trajectory vertex property...') @@ -52,17 +52,17 @@ for edge in g.edges(): if current_cf <= min({g.ep.cost_function[e] for e in trg.out_edges()}): # Set trg trajectory to src trajectory - g.vp.traj[trg] = g.vp.traj[src] + traj_prop[trg] = traj_prop[src] else: - g.vp.traj[trg] = g.vp.traj[src] + traj_prop[trg] = traj_prop[src] else: # src.out_degree() == 1 if trg.in_degree() > 1: if current_cf <= min({g.ep.cost_function[e] for e in trg.in_edges()}): - g.vp.traj[trg] = g.vp.traj[src] + traj_prop[trg] = traj_prop[src] else: - g.vp.traj[trg] = g.vp.traj[src] + traj_prop[trg] = traj_prop[src] print('Creating the dictionary of trajectories...') visitor = Visitor() -- GitLab