[Feat] Add support for Hypergraphs Interchange Format (HIF) import and export #159
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.
This PR introduces support for the Hypergraphs Interchange Format (HIF), enabling EasyGraph to exchange hypergraph data with other tools that support the HIF JSON standard.
It implements two main utility functions:
hypergraph_to_hif: Converts an EasyGraphHypergraphobject to a HIF JSON dictionary/file.hif_to_hypergraph: Loads HIF JSON data into an EasyGraphHypergraphobject.Key Changes
easygraph/utils/HIF.pycontaining the core conversion logic.easygraph/tests/test_hif.pyto ensure conversion accuracy and structural validity.easygraph/utils/__init__.pyto exposehypergraph_to_hifandhif_to_hypergraphfor easier access.Implementation Details
Schema Validation:
The converter attempts to fetch the official HIF schema (v0.1.0) to validate input/output data. It includes a fallback mechanism to skip validation if the schema cannot be fetched (offline mode).
Round-Trip Data Preservation:
custom_hif_*attributes to the object) to preserve original HIF data.direction, nestedattrs, or arbitrarymetadata) are preserved during aLoad -> EG -> Savecycle.Robust Structure Parsing:
hg.e(e.g., standard lists vs. the(edges, weights, props)tuple generated whenmerge_op="sum").hg.N_eregardless of whether it is a property or a method in different EasyGraph versions.Related Files
easygraph/utils/HIF.py(New)easygraph/tests/test_hif.py(New)easygraph/utils/__init__.py(Modified)