Skip to content
Snippets Groups Projects
Commit 754ade37 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Do not make trajectory an internal property

No need for this property to be internal.
parent 5633dea0
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"""A script that loads a segmented cf graph in the gt format, iterates """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 on all of the edges and cost functions and generates the trajectories
as done in MATLAB. Segments (nodes) have a new vertex property called 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 output is either an expanded JSON file and/or an edgelist file with
all of the trajectories. all of the trajectories.
...@@ -26,17 +26,17 @@ class Visitor(search.BFSVisitor): ...@@ -26,17 +26,17 @@ class Visitor(search.BFSVisitor):
self.trajectories = {} self.trajectories = {}
def discover_vertex(self, u): def discover_vertex(self, u):
if g.vp.traj[u] not in self.trajectories: if traj_prop[u] not in self.trajectories:
self.trajectories[g.vp.traj[u]] = [g.vp.name[u]] self.trajectories[traj_prop[u]] = [g.vp.name[u]]
else: 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 = 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: # Assign the new vertex property:
for node in g.vertices(): 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...') print('Setting trajectory vertex property...')
...@@ -52,17 +52,17 @@ for edge in g.edges(): ...@@ -52,17 +52,17 @@ for edge in g.edges():
if current_cf <= min({g.ep.cost_function[e] if current_cf <= min({g.ep.cost_function[e]
for e in trg.out_edges()}): for e in trg.out_edges()}):
# Set trg trajectory to src trajectory # Set trg trajectory to src trajectory
g.vp.traj[trg] = g.vp.traj[src] traj_prop[trg] = traj_prop[src]
else: else:
g.vp.traj[trg] = g.vp.traj[src] traj_prop[trg] = traj_prop[src]
else: else:
# src.out_degree() == 1 # src.out_degree() == 1
if trg.in_degree() > 1: if trg.in_degree() > 1:
if current_cf <= min({g.ep.cost_function[e] if current_cf <= min({g.ep.cost_function[e]
for e in trg.in_edges()}): for e in trg.in_edges()}):
g.vp.traj[trg] = g.vp.traj[src] traj_prop[trg] = traj_prop[src]
else: else:
g.vp.traj[trg] = g.vp.traj[src] traj_prop[trg] = traj_prop[src]
print('Creating the dictionary of trajectories...') print('Creating the dictionary of trajectories...')
visitor = Visitor() visitor = Visitor()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment