fix edges/links key mismatch in query, path, explain, and MCP loader (#768)

This commit is contained in:
Safi
2026-05-07 14:48:51 +01:00
parent 7c6c5242dc
commit aa2bd138b7
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -1371,6 +1371,8 @@ def main() -> None:
import json as _json
import networkx as _nx
_raw = _json.loads(gp.read_text(encoding="utf-8"))
if "links" not in _raw and "edges" in _raw:
_raw = dict(_raw, links=_raw["edges"])
try:
G = json_graph.node_link_graph(_raw, edges="links")
except TypeError:
@@ -1426,6 +1428,8 @@ def main() -> None:
print(f"error: graph file not found: {gp}", file=sys.stderr)
sys.exit(1)
_raw = json.loads(gp.read_text(encoding="utf-8"))
if "links" not in _raw and "edges" in _raw:
_raw = dict(_raw, links=_raw["edges"])
try:
G = json_graph.node_link_graph(_raw, edges="links")
except TypeError:
@@ -1474,6 +1478,8 @@ def main() -> None:
print(f"error: graph file not found: {gp}", file=sys.stderr)
sys.exit(1)
_raw = json.loads(gp.read_text(encoding="utf-8"))
if "links" not in _raw and "edges" in _raw:
_raw = dict(_raw, links=_raw["edges"])
try:
G = json_graph.node_link_graph(_raw, edges="links")
except TypeError:
+2
View File
@@ -17,6 +17,8 @@ def _load_graph(graph_path: str) -> nx.Graph:
raise FileNotFoundError(f"Graph file not found: {resolved}")
safe = resolved
data = json.loads(safe.read_text(encoding="utf-8"))
if "links" not in data and "edges" in data:
data = dict(data, links=data["edges"])
try:
return json_graph.node_link_graph(data, edges="links")
except TypeError: