Bug
graphify export graphml crashes on any graph that has a dict or list-valued attribute — e.g. a per-node metadata dict, or the graph-level hyperedges list set by attach_hyperedges():
TypeError: GraphML does not support type <class 'dict'> as data values.
TypeError: GraphML does not support type <class 'list'> as data values.
nx.write_graphml only accepts scalar attribute values. to_graphml already coerces None -> "" for this exact reason (a prior fix for #1502), but dict/list values weren't handled the same way.
Repro
import networkx as nx
from graphify.export import to_graphml
G = nx.Graph()
G.add_node("a", metadata={"kind": "file"})
G.add_node("b")
G.add_edge("a", "b")
G.graph["hyperedges"] = [{"nodes": ["a", "b"], "label": "x"}]
to_graphml(G, {0: ["a", "b"]}, "/tmp/out.graphml")
# TypeError: GraphML does not support type <class 'list'> as data values.
Also reproduces on a real ~2,300-node/4,300-edge project graph (not just this synthetic case) — every export attempt fails, and a failed attempt leaves a 0-byte .graphml file on disk that downstream tooling can mistake for a completed (if empty) export.
Fix
Opened #1830: extends to_graphml's existing None-scrubbing step to also JSON-serialize dict/list-valued attributes across graph-level, node, and edge scopes before calling nx.write_graphml. Includes a regression test mirroring the existing None-value test.
Bug
graphify export graphmlcrashes on any graph that has a dict or list-valued attribute — e.g. a per-nodemetadatadict, or the graph-levelhyperedgeslist set byattach_hyperedges():nx.write_graphmlonly accepts scalar attribute values.to_graphmlalready coercesNone -> ""for this exact reason (a prior fix for #1502), but dict/list values weren't handled the same way.Repro
Also reproduces on a real ~2,300-node/4,300-edge project graph (not just this synthetic case) — every export attempt fails, and a failed attempt leaves a 0-byte
.graphmlfile on disk that downstream tooling can mistake for a completed (if empty) export.Fix
Opened #1830: extends
to_graphml's existing None-scrubbing step to also JSON-serialize dict/list-valued attributes across graph-level, node, and edge scopes before callingnx.write_graphml. Includes a regression test mirroring the existing None-value test.