| 46 | |
| 47 | |
| 48 | def _load_global_graph() -> nx.Graph: |
| 49 | if _GLOBAL_GRAPH.exists(): |
| 50 | from graphify.security import check_graph_file_size_cap |
| 51 | check_graph_file_size_cap(_GLOBAL_GRAPH) |
| 52 | data = json.loads(_GLOBAL_GRAPH.read_text(encoding="utf-8")) |
| 53 | if "links" not in data and "edges" in data: |
| 54 | data = dict(data, links=data["edges"]) |
| 55 | try: |
| 56 | return _jg.node_link_graph(data, edges="links") |
| 57 | except TypeError: |
| 58 | return _jg.node_link_graph(data) |
| 59 | return nx.Graph() |
| 60 | |
| 61 | |
| 62 | def _save_global_graph(G: nx.Graph) -> None: |