Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| from pathlib import Path | |
| from ..ingest.store import read_json, write_json | |
| from .models import Graph, graph_from_dict, graph_to_dict | |
| def save_graph(graph: Graph, path) -> None: | |
| write_json(graph_to_dict(graph), path) | |
| def load_graph(path) -> Graph: | |
| p = Path(path) | |
| return graph_from_dict(read_json(p)) if p.exists() else Graph() | |