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

Allow the independent creation of trajectory lists

The motivation is to be able to create the files `*traj*.json` for
only a component of the graph, so that `plot_traj.py` can plot the
trajectories in a single component, with different colors for
different trajectories.
parent 2aae5ba7
No related branches found
No related tags found
No related merge requests found
......@@ -28,9 +28,11 @@ def create_traj_list(
else:
traj_vert_ind[traj_prop[n]] = [n]
traj_vert_ind = [traj_vert_ind[t] for t in range(len(traj_vert_ind))]
# An element of traj_vert_ind is a trajectory, represented by a list
# of vertex indices.
traj_vert_ind = [traj_vert_ind[t] for t in sorted(traj_vert_ind)]
# sorted(traj_vert_ind) instead of range(len(traj_vert_ind))
# because create_traj_list can be called for a component of the
# graph. An element of traj_vert_ind is a trajectory, represented
# by a list of vertex indices.
print("Number of trajectories: ", len(traj_vert_ind))
......@@ -87,3 +89,28 @@ def create_traj_list(
)
print("Created expanded_traj.json.")
if __name__ == "__main__":
import sys
import graph_tool
from graph_tool import topology
if len(sys.argv) != 2:
sys.exit("Required argument: input-graph")
g = graph_tool.load_graph(sys.argv[1])
print("Input graph:")
print("Number of vertices:", g.num_vertices())
print("Number of edges:", g.num_edges())
print("Internal properties:")
g.list_properties()
create_traj_list(
topology.topological_sort(g),
g.vp["traj"],
g.vp["name"],
g.vp["inst_eddies"],
g.gp["orientation"],
g.gp["e_overestim"],
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment