From fe8b87c5db8966aff31864ec2c9a7041ea35f8d8 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Fri, 1 Dec 2023 18:59:14 +0100 Subject: [PATCH] Save trajectories as lists of vertex indices This is useful to find the shortest path between the beginning and the end of a trajectory, or to create a histogram of the number of trajectories per component. --- Trajectories/trajectories.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Trajectories/trajectories.py b/Trajectories/trajectories.py index df67e370..b8f17554 100755 --- a/Trajectories/trajectories.py +++ b/Trajectories/trajectories.py @@ -215,6 +215,13 @@ t0 = t1 # Save: +with open("traj_vert_ind.json", "w") as outfile: + json.dump(traj_vert_ind, outfile, separators=(",", ":"), default=int) + # (We specify default because the type of vertex indices is + # numpy.int32, not JSON serializable.) + +print("Created traj_vert_ind.json.") + with open("traj_segm.json", "w") as outfile: json.dump(traj_segm, outfile, separators=(",", ":")) -- GitLab