From ffd8906c6c3b323359ff9c3f23234fa129445145 Mon Sep 17 00:00:00 2001 From: Safi Date: Wed, 8 Apr 2026 19:02:05 +0100 Subject: [PATCH] fix: ensure Cypher node label always starts with a letter (#84) --- graphify/export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphify/export.py b/graphify/export.py index 2870fdc..d363aa3 100644 --- a/graphify/export.py +++ b/graphify/export.py @@ -282,7 +282,8 @@ def to_cypher(G: nx.Graph, output_path: str) -> None: for node_id, data in G.nodes(data=True): label = _cypher_escape(data.get("label", node_id)) node_id_esc = _cypher_escape(node_id) - ftype = re.sub(r"[^A-Za-z0-9_]", "", data.get("file_type", "unknown").capitalize()) or "Entity" + _ft = re.sub(r"[^A-Za-z0-9_]", "", data.get("file_type", "unknown").capitalize()) + ftype = (_ft if _ft and _ft[0].isalpha() else "Entity") lines.append(f"MERGE (n:{ftype} {{id: '{node_id_esc}', label: '{label}'}});") lines.append("") for u, v, data in G.edges(data=True):