Skip to content

Add GraphFormatConverter interface and createFormatConverter factory#3

Merged
davidkpiano merged 5 commits intomainfrom
claude/graphml-format-converters-JZqM0
Feb 16, 2026
Merged

Add GraphFormatConverter interface and createFormatConverter factory#3
davidkpiano merged 5 commits intomainfrom
claude/graphml-format-converters-JZqM0

Conversation

@davidkpiano
Copy link
Copy Markdown
Member

Introduce a lightweight extensible converter pattern for bidirectional
graph format conversion. Third parties can implement GraphFormatConverter
to plug in custom formats with a standardized contract.

  • GraphFormatConverter interface in types.ts
  • createFormatConverter() factory in formats/converter.ts
  • Pre-built converters: adjacencyListConverter, edgeListConverter, graphmlConverter
  • Exported from main entry and formats/graphml subpath
  • Tests covering all converters plus a custom converter example

https://claude.ai/code/session_01BmmrXgmGWZtNsnwi6HR1dq

Introduce a lightweight extensible converter pattern for bidirectional
graph format conversion. Third parties can implement GraphFormatConverter<T>
to plug in custom formats with a standardized contract.

- GraphFormatConverter<TSerial> interface in types.ts
- createFormatConverter() factory in formats/converter.ts
- Pre-built converters: adjacencyListConverter, edgeListConverter, graphmlConverter
- Exported from main entry and formats/graphml subpath
- Tests covering all converters plus a custom converter example

https://claude.ai/code/session_01BmmrXgmGWZtNsnwi6HR1dq
Six new bidirectional format converters, each with to*/from* functions
and a pre-built converter object:

- JGF (JSON Graph Format) — JSON-native, formal spec, metadata-extensible
- Cytoscape.js JSON — compound graphs via parent, positions, web ecosystem
- D3.js JSON — { nodes, links } for force-directed layouts
- GEXF — Gephi native, pid hierarchy, viz module (requires fast-xml-parser)
- GML — nested node blocks for hierarchy, graphics properties
- TGF — minimal id+label format, trivial to parse

Also adds "Why this library?" section to README explaining the
computational-layer-between-formats positioning, and updates the
formats table with all 10 supported formats.

https://claude.ai/code/session_01BmmrXgmGWZtNsnwi6HR1dq
Every from* function now validates its input before processing:
- JSON formats (JGF, Cytoscape, D3): check for object, required arrays
- Text formats (GML, TGF): check for string, non-empty
- XML formats (GEXF, GraphML): wrap parse errors, validate root elements

29 new tests covering: null/undefined input, missing required fields,
invalid XML, empty graphs, malformed structures, edge cases (GML
comments, TGF missing separator, D3 post-simulation object refs).

https://claude.ai/code/session_01BmmrXgmGWZtNsnwi6HR1dq
Tests verify that converted graph data works with the actual libraries
in both directions (our Graph → library and library → our Graph),
including round-trips with mutations and layout positions.

Adds cytoscape and d3-force as optional peer dependencies.

https://claude.ai/code/session_01BmmrXgmGWZtNsnwi6HR1dq
@davidkpiano davidkpiano merged commit 28883da into main Feb 16, 2026
@github-actions github-actions Bot mentioned this pull request Feb 16, 2026
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