blob: 1cafb8dfcd4b76e3055c3f511f95c804e16b9961 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import yaml
def save_paths_to_yaml(paths, filename="paths.yml"):
# to facilitate testing for snowplow (do not have to redo the drone part each time)
serializable_paths = {
k: [[u, v] for (u, v) in v] for k, v in paths.items()
}
with open(f"paths/{filename}", 'w') as f:
yaml.dump(serializable_paths, f)
def load_paths_from_yaml(graph, filename="paths.yml"):
with open(filename, 'r') as f:
raw_paths = yaml.safe_load(f)
# Reconstruit le format avec des tuples (u, v)
paths = {
k: [tuple(edge) for edge in v] for k, v in raw_paths.items()
}
return paths
|