From 61cb34ee2f845de370a5b6102397a3dacd2d8931 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 18 May 2022 22:08:01 +0200
Subject: [PATCH] Polish

---
 cost_function.py   |  4 ++--
 gt_matlab_trajs.py | 15 ++++++---------
 segments.py        |  6 +++---
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/cost_function.py b/cost_function.py
index 43771446..f182fc48 100755
--- a/cost_function.py
+++ b/cost_function.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 
-"""A script that takes the graph of segments without cost functions
-and computes the non-local cost functions applied to edges.
+"""This script takes the graph of segments without cost functions and
+computes the non-local cost functions applied to edges.
 
 Input:
 
diff --git a/gt_matlab_trajs.py b/gt_matlab_trajs.py
index 83256902..21c09ac2 100755
--- a/gt_matlab_trajs.py
+++ b/gt_matlab_trajs.py
@@ -38,7 +38,7 @@ g.vp['traj'] = g.new_vp('int')
 for node in g.vertices():
     g.vp.traj[node] = g.vp.name[node]
 
-print('Algorithm starting...')
+print('Setting trajectory vertex property...')
 
 for edge in g.edges():
     current_cf = g.ep.cost_function[edge]
@@ -56,7 +56,7 @@ for edge in g.edges():
             else:
                 g.vp.traj[trg] = g.vp.traj[src]
     else:
-        # Source is a continuation or root with one out
+        # src.out_degree() == 1
         if trg.in_degree() > 1:
             if current_cf <= min({g.ep.cost_function[e]
                                   for e in trg.in_edges()}):
@@ -64,18 +64,15 @@ for edge in g.edges():
         else:
             g.vp.traj[trg] = g.vp.traj[src]
 
-print('Algorithm done, saving...')
-
-# Make a dictionary of trajectories:
-
+print('Creating the dictionary of trajectories...')
 visitor = Visitor()
 search.bfs_search(g, visitor = visitor)
+print("Number of trajectories: ", len(visitor.trajectories))
 
 with open("trajectories.json", "w") as outfile:
     json.dump(visitor.trajectories, outfile, indent = 4)
 
-# Setup a new trajectory that holds the expanded segments:
-
+print('Creating the dictionary of expanded trajectories...')
 expanded_trajectories = {}
 
 for trajectory in visitor.trajectories.values():
@@ -101,4 +98,4 @@ for trajectory in visitor.trajectories.values():
 with open("expanded_trajectories.json", "w") as outfile:
     json.dump(expanded_trajectories, outfile, indent = 4)
 
-print(f'Done saving json: {len(visitor.trajectories)} trajectories.')
+print('Done')
diff --git a/segments.py b/segments.py
index f59f4464..6807799f 100755
--- a/segments.py
+++ b/segments.py
@@ -2,9 +2,9 @@
 
 """Collapses the input graph of instantaneous eddies into a new graph:
 the graph of segments. A vertex of the new graph is a segment. Input
-file should be an edgelist in CSV format. The new graph is output in a
-file with suffix ".gt", for the binary format of Graph-tool, or
-".graphml".
+file should be an edgelist in CSV format. The new graph is output in
+the binary format of Graph-tool (file with suffix ".gt") or in GraphML
+format (suffix ".graphml".)
 
 """
 
-- 
GitLab