Hypergraph-DB¶
Hypergraph-DB is a lightweight, flexible, and Python-based database designed to model and manage hypergraphsβa generalized graph structure where edges (hyperedges) can connect any number of vertices. This makes Hypergraph-DB an ideal solution for representing complex relationships between entities in various domains, such as knowledge graphs, social networks, and scientific data modeling.
β¨ Features¶
- π Lightweight & Fast: Pure Python implementation with minimal dependencies
- π Hypergraph Support: Native support for hyperedges connecting multiple vertices
- πΎ Persistence: Built-in serialization and loading capabilities
- π Visualization: Interactive hypergraph visualization in web browsers
- π Flexible Queries: Rich query capabilities for vertices and hyperedges
- π οΈ Simple API: Intuitive and easy-to-use interface
π― Use Cases¶
- Knowledge Graphs: Model complex relationships between entities
- Social Networks: Represent group interactions and multi-party relationships
- Scientific Data: Model complex dependencies in research data
- Recommendation Systems: Capture multi-way interactions between users, items, and contexts
π Performance¶
Hypergraph-DB is designed for efficiency. Here are some performance benchmarks:
Vertices | Hyperedges | Add Vertices | Add Edges | Query Time | Total Time |
---|---|---|---|---|---|
100,000 | 20,000 | 0.12s | 0.17s | 0.04s | 0.58s |
500,000 | 100,000 | 0.85s | 1.07s | 0.22s | 3.34s |
1,000,000 | 200,000 | 1.75s | 1.82s | 0.51s | 6.60s |
π Quick Start¶
Installation¶
Basic Usage¶
from hyperdb import HypergraphDB
# Create a hypergraph
hg = HypergraphDB()
# Add vertices with attributes
hg.add_v(1, {"name": "Alice", "age": 30})
hg.add_v(2, {"name": "Bob", "age": 25})
hg.add_v(3, {"name": "Charlie", "age": 35})
# Add hyperedges connecting multiple vertices
hg.add_e((1, 2), {"relation": "friends"})
hg.add_e((1, 2, 3), {"relation": "project_team"})
# Query the hypergraph
print(f"Vertices: {hg.all_v}")
print(f"Edges: {hg.all_e}")
# Visualize the hypergraph
hg.show() # Opens visualization in web browser
π Documentation¶
- Getting Started: Installation and basic setup
- API Reference: Complete API documentation
- Visualization Guide: Interactive hypergraph visualization
- Examples: Practical examples and tutorials
π€ Contributing¶
We welcome contributions! Please see our GitHub repository for more information.
π License¶
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
π¬ Contact¶
- Author: Yifan Feng
- Email: evanfeng97@qq.com
- GitHub: @iMoonLab
Built with β€οΈ by the iMoonLab team