Add GraphFormatConverter interface and createFormatConverter factory#3
Merged
davidkpiano merged 5 commits intomainfrom Feb 16, 2026
Merged
Conversation
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
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
https://claude.ai/code/session_01BmmrXgmGWZtNsnwi6HR1dq