### Install Hypergraph-DB from Source - bash Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Clones the Hypergraph-DB repository from GitHub and installs dependencies listed in the requirements file. ```bash # Clone the repository git clone https://github.com/iMoonLab/Hypergraph-DB.git cd Hypergraph-DB # Install dependencies (if any) pip install -r requirements.txt ``` -------------------------------- ### Install Stable Hypergraph-DB via pip (Bash) Source: https://github.com/imoonlab/hypergraph-db/blob/main/docs/get_started/install.rst Installs the stable version (0.1.0) of the Hypergraph-DB library using the pip package manager. This command fetches the package from PyPI. ```bash pip install hypergraph-db ``` -------------------------------- ### Install Hypergraph-DB via pip - bash Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Installs the Hypergraph-DB library from the Python Package Index using the pip package manager. ```bash pip install hypergraph-db ``` -------------------------------- ### Install Nightly Hypergraph-DB via pip (Bash) Source: https://github.com/imoonlab/hypergraph-db/blob/main/docs/get_started/install.rst Installs the nightly development version (0.1.1) of the Hypergraph-DB library directly from the GitHub repository using pip. This version may be unstable. ```bash pip install git+https://github.com/iMoonLab/Hypergraph-DB.git ``` -------------------------------- ### Query Vertices and Hyperedges - Python Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Demonstrates how to retrieve all vertex and hyperedge IDs, and how to query specific vertices and hyperedges by their ID or tuple to get their properties. ```python # Get all vertices and hyperedges print(hg.all_v) print(hg.all_e) # Query a specific vertex print(hg.v(1)) # Query a specific hyperedge print(hg.e((1, 2, 3))) ``` -------------------------------- ### Query Neighbors and Incident Edges - Python Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Provides examples of how to find neighboring vertices connected to a given vertex via hyperedges and how to find all hyperedges incident to a vertex. ```python # Get neighbors of a vertex print(hg.nbr_v(1)) hg.add_e((1, 4, 6), {"relation": "team"}) print(hg.nbr_v(1)) # Get incident hyperedges of a vertex print(hg.nbr_e_of_v(1)) ``` -------------------------------- ### Create and Populate Hypergraph - Python Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Initializes a HypergraphDB instance and adds multiple vertices with properties and hyperedges connecting various vertices with properties. ```python from hyperdb import HypergraphDB # Initialize the hypergraph hg = HypergraphDB() # Add vertices hg.add_v(1, {"name": "Alice", "age": 30, "city": "New York"}) hg.add_v(2, {"name": "Bob", "age": 24, "city": "Los Angeles"}) hg.add_v(3, {"name": "Charlie", "age": 28, "city": "Chicago"}) hg.add_v(4, {"name": "David", "age": 35, "city": "Miami"}) hg.add_v(5, {"name": "Eve", "age": 22, "city": "Seattle"}) hg.add_v(6, {"name": "Frank", "age": 29, "city": "Houston"}) hg.add_v(7, {"name": "Grace", "age": 31, "city": "Phoenix"}) hg.add_v(8, {"name": "Heidi", "age": 27, "city": "San Francisco"}) hg.add_v(9, {"name": "Ivan", "age": 23, "city": "Denver"}) hg.add_v(10, {"name": "Judy", "age": 26, "city": "Boston"}) # Add hyperedges hg.add_e((1, 2, 3), {"type": "friendship", "duration": "5 years"}) hg.add_e((1, 4), {"type": "mentorship", "topic": "career advice"}) hg.add_e((2, 5, 6), {"type": "collaboration", "project": "AI Research"}) hg.add_e((4, 5, 7, 9), {"type": "team", "goal": "community service"}) hg.add_e((3, 8), {"type": "partnership", "status": "ongoing"}) hg.add_e((9, 10), {"type": "neighbors", "relationship": "friendly"}) hg.add_e((1, 2, 3, 7), {"type": "collaboration", "field": "music"}) hg.add_e((2, 6, 9), {"type": "classmates", "course": "Data Science"}) ``` -------------------------------- ### Save and Load Hypergraph - Python Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Demonstrates how to save the current state of the hypergraph to a file using serialization and how to load a hypergraph from a previously saved file. ```python # Save the hypergraph to a file hg.save("my_hypergraph.hgdb") # Load the hypergraph from a file hg2 = HypergraphDB(storage_file="my_hypergraph.hgdb") print(hg2.all_v) print(hg2.all_e) ``` -------------------------------- ### Calculate Vertex and Hyperedge Degrees - Python Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Illustrates how to calculate the degree of a vertex (number of incident hyperedges) and the degree of a hyperedge (number of vertices it connects). ```python # Get the degree of a vertex print(hg.degree_v(1)) # Get the degree of a hyperedge print(hg.degree_e((2, 5, 6))) ``` -------------------------------- ### Update and Remove Graph Elements - Python Source: https://github.com/imoonlab/hypergraph-db/blob/main/README.md Shows how to update the properties of an existing vertex and how to remove vertices and hyperedges from the graph, demonstrating the resulting state. ```python # Update a vertex hg.update_v(1, {"name": "Smith"}) print(hg.v(1)) # Remove a vertex hg.remove_v(3) print(hg.all_v) print(hg.all_e) # Remove a hyperedge hg.remove_e((1, 4)) print(hg.all_e) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.