Spaces:
Sleeping
Sleeping
File size: 378 Bytes
8db761b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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()
|