MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _load_cli_graph

Function _load_cli_graph

graphify/cli.py:1178–1195  ·  view source on GitHub ↗

Load graph.json as a directed graph for a node-lookup command, or exit 1. Directed so stored caller->callee direction survives the load.

(gp: Path)

Source from the content-addressed store, hash-verified

1176
1177
1178def _load_cli_graph(gp: Path):
1179 """Load graph.json as a directed graph for a node-lookup command, or exit 1.
1180
1181 Directed so stored caller->callee direction survives the load.
1182 """
1183 from networkx.readwrite import json_graph
1184 from graphify.paths import consumed, read_graph_json
1185
1186 if not gp.exists():
1187 print(f"error: graph file not found: {gp}", file=sys.stderr)
1188 sys.exit(1)
1189 _enforce_graph_size_cap_or_exit(gp)
1190 raw = read_graph_json(gp)
1191 if "links" not in raw and "edges" in raw:
1192 raw = dict(raw, links=raw["edges"])
1193 raw = {**raw, "directed": True}
1194 raw = dict(raw, nodes=consumed(raw["nodes"]), links=consumed(raw["links"]))
1195 return json_graph.node_link_graph(raw, edges="links")
1196
1197
1198def _hook_strict_enabled(flag: bool) -> bool:

Callers 1

dispatch_commandFunction · 0.85

Calls 3

read_graph_jsonFunction · 0.90
consumedFunction · 0.90

Tested by

no test coverage detected