Add KBMAG serialization for WordGraph - #16
Closed
james-d-mitchell wants to merge 1 commit into
Closed
james-d-mitchell wants to merge 1 commit into
james-d-mitchell wants to merge 1 commit into
Conversation
Read and write dense deterministic and sparse KBMAG records through streams or strings. Preserve transition labels, undefined transitions, parallel targets, isolated nodes, and the alphabet size. Use initial state 1 for nonempty graphs and an empty accepting list. Document the encoding and parsing algorithms and the supported numeric KBMAG subset. Report invalid values, fields, sources, and input locations. Include round-trip, malformed-input, stream, and documentation tests. Validated the quick WordGraphIO, WordGraph, and WordGraphView suites, documentation examples and build, pre-push hooks, and 24 round trips through KBMAG's fsafilter in dense and sparse formats. AI assistance: OpenAI Codex implemented the code, documentation, tests, and commit message. Co-authored-by: Codex OpenAI <codex@openai.com>
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.
Add a KBMAG interchange format that preserves the complete
WordGraphtransition table, including labels, missing transitions, isolated nodes, and unused labels. For example, edges(s, a, t)and(s, b, t)with different labels survive a round trip unchanged.The new APIs provide:
word_graph::to_kbmag_string(graph, format)andword_graph::write_kbmag(output, graph, format), with dense deterministic or sparse output.make<WordGraph<Node>>(text)andmake<WordGraph<Node>>(input)for strings and streams.The writer converts node and label indices to KBMAG's one-based numbering and includes
numTransitions. The reader processes one row at a time without building a second complete transition table. Nonempty graphs useinitial := [1]; empty graphs useinitial := []; all graphs useaccepting := [].Import supports the documented numeric subset:
simplestate and alphabet records, DFA flags, dense deterministic or sparse tables, comments, line continuations, and sparse defaults. Unsupported automaton semantics are rejected, including nonempty accepting lists, other initial states, nondeterminism, and external transition files. Additional metadata is skipped without evaluating GAP code.Validation:
test_word_graph_io,test_word_graph, andtest_word_graph_view; all 118 test cases selected by[quick]passed.make doc-test: all 43 documentation examples passed.make doc, documentation order/line-break checks, and generated umbrella-header checks passed. The documentation build reports existing unrelated warnings.fsafilter, covering both formats, empty graphs, and zero out-degree, preserved graph equality.This PR targets
codex/word-graph-kbmag-base, a snapshot of upstream commit52d350f21170ed14b7f9409132746fdadeb10524, because this fork'smainis behind that commit. The comparison contains only the KBMAG implementation commit.AI assistance: OpenAI Codex implemented the code, documentation, and tests, performed validation, and prepared this pull request. The commit includes Codex co-author credit.