hypergraphx
hypergraphx copied to clipboard
Refactored code common to all core classes
I created 2 interfaces with code shared across the different core Hypergraph classes. Below is a Mermaid diagram indicating the inheritance hierarchy.
classDiagram
class IHypergraph
class DirectedHypergraph
class IUndirectedHypergraph
class Hypergraph
class MultiplexHypergraph
class TemporalHypergraph
IHypergraph <|-- DirectedHypergraph
IHypergraph <|-- IUndirectedHypergraph
IUndirectedHypergraph <|-- Hypergraph
IUndirectedHypergraph <|-- MultiplexHypergraph
IUndirectedHypergraph <|-- TemporalHypergraph
I've included detailed commit messages, as well as comments describing my changes. The key differences in functionality now, though are:
- Instead of using edge_id's to access values in the _edge_metadata structures, I've set them up to index them directly, using the edges' tuples. The previous method seemed needlessly complicated, at least within the class definitions, since the edges were used to look up the edge_ids every time.
- I added lots more type checking to the class constructors and methods, to cut down on ambiguity (especially around the _edge_list dicts, may rename that later)
- edge_metadata is typechecked to ensure only lists of dictionaries are allowed, no sets, dicts, or anything else like before. that way, the IHypergraph constructor can reliably map them to dicts of type Dict[Tuple, Dict].
This looks very useful! Thanks a lot for working on it, it is very needed. I'll take some time to review the code (may be slow due to holidays) and reach out for further questions / merge the code:)