mirror of
https://github.com/safishamsi/graphify.git
synced 2026-09-22 21:45:58 +00:00
fix edges/links key mismatch in query, path, explain, and MCP loader (#768)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user