hgraph/
│
├── core/
│ ├── __init__.py
│ ├── node.py # contains Node base class
│ ├── edge.py # contains Edge + Hyperedge classes
│ ├── config.py # contains NodeConfig, EdgeConfig, HyperedgeConfig
│ ├── registry.py # schema registry
│ ├── validator.py # constraint checking logic
│ └── hypergraph.py # Hypergraph implementation
Next Steps:
-
update_edge()
/update_hyperedge()
should re-validate constraints. -
Support directed multigraphs: allow multiple edge types between same nodes. - Allow custom constraints, e.g. via
@validator
on specific types.
Current Status:
- We have dynamic runtime registration via
SchemaRegistry
.
Next Steps:
- Implement
save_to_json(path: str)
/load_from_json(path: str)
- Implement
save_to_parquet(path: str)
/load_from_parquet(path: str)
- Support typed deserialization using the registry
- Design a SQLite backend adapter with JSONB columns for flexibility
- Design a DuckDB backend adapter
- Add
export_schema()
to emit JSON Schema (for validation, tooling, docs)
Powerful querying is central to all knowledge systems.
Design Options:
-
find_edges(source=..., type=..., target=...)
-
get_neighbors(node_id)
-
find_path(start, end, max_depth=N)
-
match(pattern: QueryPattern)
(think: basic Datalog-like DSL)
Bonus:
- Support filtering by config constraints (e.g. “only functional edges”)
Once configs define all logical semantics, make them actionable.
Capabilities to Add:
-
infer_transitive_closure()
for transitive edges -
auto_add_inverse_edges()
ifinverse
is set -
check_consistency()
across the whole graph - Constraint-based inferencing and validation at rest (like RDF validators)
Goal: Make it easy to test and extend.
- Add full
pytest
suite for:- Edges
- Hyperedges
- Constraint violations
- Registry loading
- Enable
mypy
andruff
orblack
linting - Provide CLI via
hgraph.cli
to:- Create/load graphs
- Export to JSON/Graphviz
- Validate graphs
-
.to_graphviz()
to generate .dot files - Optional dependency for
networkx
export -
.summary()
to list:- All registered types
- Node/edge counts per type
- Violations (if any)
- Generate Markdown docs from model definitions (with constraints)
- Add tutorial notebooks or CLI walkthrough
- Auto-generate schemas for IDE support / OpenAPI-style UX
- Import RDF/OWL and map classes/properties to
hgraph
Node
/Edge
/Hyperedge
types - Export to RDF/OWL from any
hgraph
graph - Support custom vocabularies and automatic type inference when importing
- Ensure semantic compatibility with SKOS, RDFS, OWL2, and Wikidata-style ontologies
- Define namespaces (like
core.person
,finance.transaction
) - Graphs can declare dependencies on other graphs (like modules or ontologies)
- Enable merging graphs under compatible or intersecting namespaces
- Namespace-specific type resolution and IRI mapping for RDF interop
- Allow teams to fork a graph and work on separate branches
- Introduce merge requests (MRs) between branches with:
- Semantic diffing
- Conflict detection
- User-defined merge strategies (e.g., override, ignore, union)
- Design a merge resolution layer with interactive hooks
- Define graph schema versions
- Support deprecations, renames, field migrations, and type changes
- CLI tooling or migration DSL:
hgraph migrate --from v1.0 --to v2.0
- Add temporal dimensions to edges/hyperedges (e.g., valid_from, valid_to)
- Integrate provenance tracking:
- Who added this?
- What source did it come from?
- Which inference engine proposed it?
Phase | Theme | Deliverables |
---|---|---|
✅ 1 | Constraint System | Edge & Hyperedge validation |
✅ 2 | Hypergraph Core API | CRUD, config-driven semantics |
🔜 3 | Schema Registry + Typed Save/Load | JSON + SQLite + schema-aware I/O |
🔜 4 | Query Engine | .get_neighbors() , .find_by_type() , etc. |
🔜 5 | Graph Visualization | Graphviz, NetworkX, CLI-based |
🔜 6 | Inference Layer | Transitivity, Inverses, Closure |
🔜 7 | Graph Composition | Namespaces, Graph dependencies, Module loading |
🔜 8 | RDF/OWL Interoperability | Import/export OWL/RDF → hgraph |
🔜 9 | Branching, Merging, and Conflicts | Merge Requests, Git-style ops |
🔜10 | Schema Versioning + Migrations | DSL or config system for versioned graphs |
🔜11 | Provenance + Temporal Reasoning | Time-bound relations, "who said what" support |
class OpenAccountGraph(Hypergraph):
namespace = "finance.accounting"
dependencies = [
GraphDependency(namespace="core.person", version=">=1.0.0"),
GraphDependency(namespace="core.money", version="~2.1"),
]