From 80fce23f2b99dd2f7fbe9e4eacc62c3ca9c09bf1 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 20 Apr 2022 11:52:18 +0200 Subject: [PATCH] Polish --- cost_function.py | 35 +++++++++++++++++------------------ segments.py | 8 ++++---- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cost_function.py b/cost_function.py index 4058f2f4..8c27ce7e 100755 --- a/cost_function.py +++ b/cost_function.py @@ -1,13 +1,22 @@ #!/usr/bin/env python3 -# A script that takes a segmented graph in the gt format and performs the -# non-local cost function calculation where each edge will have a cost -# function assigned to it. -# Inputs (to be changed within the script): - # node_id_param_file - # gt graph - # shapefiles -# Output: a gt graph with cost functions and an xml graph with cost functions +"""A script that takes a segmented graph in the gt format and performs +the non-local cost function calculation where each edge will have a +cost function assigned to it. + +Input: + +- "node_id_param.json", expected to be in the current directory + +- the graph of segments, "segments.gt" or "segments.graphml", expected + to be in the current directory + +- shapefiles, specified as command line arguments + +Output: the graph of segments with cost functions, +'segments_cost_functions.gt' + +""" import graph_tool import time @@ -297,15 +306,5 @@ for edge in g.edges(): g.ep.nl_cost_function[edge] = cf -################################ -# Writing to an GT Graph File # -################################ - -#g.save("segments_cyclo_gl_cf.xml") -#print("Done writing xml.") -print("Done writing gt.") -#g.save('segmented_cf.gv', fmt = "dot") -#print("Done writing dot file.") - g.save('segments_cost_functions.gt') print('All done') diff --git a/segments.py b/segments.py index 87666697..89a696d6 100755 --- a/segments.py +++ b/segments.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -"""Collapses the input graph into a new graph: the graph of -segments. A vertex of the new graph is a segment. The new graph is -output in the binary format of graph-tool. Input file should be an -edgelist in CSV format. Output file can have suffix ".gt" or +"""Collapses the input graph of instantaneous eddies into a new graph: +the graph of segments. A vertex of the new graph is a segment. The new +graph is output in the binary format of Graph-tool. Input file should +be an edgelist in CSV format. Output file can have suffix ".gt" or ".graphml". """ -- GitLab