Skip to content

fix: accept 'links' key from NetworkX <=3.1 alongside 'edges'#212

Closed
mrsyb wants to merge 1 commit into
safishamsi:v4from
mrsyb:fix/accept-networkx-links-key
Closed

fix: accept 'links' key from NetworkX <=3.1 alongside 'edges'#212
mrsyb wants to merge 1 commit into
safishamsi:v4from
mrsyb:fix/accept-networkx-links-key

Conversation

@mrsyb

@mrsyb mrsyb commented Apr 11, 2026

Copy link
Copy Markdown

NetworkX changed its node_link_data() default edge key from 'links' (<=3.1) to 'edges' (>=3.2). Any data serialised with an older NetworkX version — or any serialiser that follows the original JSON Graph Format spec — uses 'links', causing graphify to silently produce graphs with zero edges.

Changes:

  • validate.py: fall back to data['links'] when data['edges'] is absent
  • build.py: normalise 'links' -> 'edges' at the top of build_from_json()

Both fixes are backward-compatible: data already using 'edges' is unaffected.

Tests added:

  • test_build_from_json_with_links_key (old-style 'links' key)
  • test_build_from_json_with_edges_key (new-style 'edges' key, current NX)
  • test_links_key_accepted_as_edges (validate accepts 'links')
  • test_edges_key_takes_priority_over_links (priority order is correct)

NetworkX changed its node_link_data() default edge key from 'links' (<=3.1)
to 'edges' (>=3.2). Any data serialised with an older NetworkX version — or
any serialiser that follows the original JSON Graph Format spec — uses 'links',
causing graphify to silently produce graphs with zero edges.

Changes:
- validate.py: fall back to data['links'] when data['edges'] is absent
- build.py: normalise 'links' -> 'edges' at the top of build_from_json()

Both fixes are backward-compatible: data already using 'edges' is unaffected.

Tests added:
- test_build_from_json_with_links_key  (old-style 'links' key)
- test_build_from_json_with_edges_key  (new-style 'edges' key, current NX)
- test_links_key_accepted_as_edges     (validate accepts 'links')
- test_edges_key_takes_priority_over_links  (priority order is correct)
safishamsi added a commit that referenced this pull request Apr 11, 2026
- build/validate: accept NetworkX <=3.1 "links" key alongside "edges" (#212)
- __main__: skip version check during install/uninstall, deduplicate paths (#220)
- all file IO: explicit encoding="utf-8" to prevent crashes on Windows CJK locales (#204)
- hooks: add newline="\n" on write to prevent CRLF shebang breakage on Windows (#204)
- export: strip trailing .md from safe_name so "CLAUDE.md" doesn't become "CLAUDE.md.md" (#221)
- report: add Community Hubs navigation block so Obsidian vault stays connected (#221)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Owner

Cherry-picked into v0.4.2 — thank you!

@safishamsi safishamsi closed this Apr 11, 2026
joyshmitz pushed a commit to joyshmitz/graphify that referenced this pull request Apr 13, 2026
…hamsi#221 into 0.4.2

- build/validate: accept NetworkX <=3.1 "links" key alongside "edges" (safishamsi#212)
- __main__: skip version check during install/uninstall, deduplicate paths (safishamsi#220)
- all file IO: explicit encoding="utf-8" to prevent crashes on Windows CJK locales (safishamsi#204)
- hooks: add newline="\n" on write to prevent CRLF shebang breakage on Windows (safishamsi#204)
- export: strip trailing .md from safe_name so "CLAUDE.md" doesn't become "CLAUDE.md.md" (safishamsi#221)
- report: add Community Hubs navigation block so Obsidian vault stays connected (safishamsi#221)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
safishamsi added a commit that referenced this pull request Apr 23, 2026
- build/validate: accept NetworkX <=3.1 "links" key alongside "edges" (#212)
- __main__: skip version check during install/uninstall, deduplicate paths (#220)
- all file IO: explicit encoding="utf-8" to prevent crashes on Windows CJK locales (#204)
- hooks: add newline="\n" on write to prevent CRLF shebang breakage on Windows (#204)
- export: strip trailing .md from safe_name so "CLAUDE.md" doesn't become "CLAUDE.md.md" (#221)
- report: add Community Hubs navigation block so Obsidian vault stays connected (#221)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
matzls pushed a commit to matzls/graphify that referenced this pull request May 10, 2026
…hamsi#221 into 0.4.2

- build/validate: accept NetworkX <=3.1 "links" key alongside "edges" (safishamsi#212)
- __main__: skip version check during install/uninstall, deduplicate paths (safishamsi#220)
- all file IO: explicit encoding="utf-8" to prevent crashes on Windows CJK locales (safishamsi#204)
- hooks: add newline="\n" on write to prevent CRLF shebang breakage on Windows (safishamsi#204)
- export: strip trailing .md from safe_name so "CLAUDE.md" doesn't become "CLAUDE.md.md" (safishamsi#221)
- report: add Community Hubs navigation block so Obsidian vault stays connected (safishamsi#221)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants