Library / SDK
iMoonLab/DeepHypergraph avatar
iMoonLab/DeepHypergraph

DeepHypergraph (DHG): a PyTorch library for graph and hypergraph computation

A pytorch library for graph and hypergraph computation.

887 stars89 forksPythonApache-2.0

At a glance

What is it?
DHG wraps graphs, directed graphs, bipartite graphs and hypergraphs in one PyTorch structure API, with spectral and spatial operators attached to the structure itself. It suits researchers who need beyond-pairwise message passing and are willing to accept a beta-stage library with a thin release cadence.
Who is it for?
Adopt DHG if you are doing research that needs hypergraph message passing, spectral operators, or Auto-ML tuning through dhg.experiments on top of Optuna, and you are comfortable reading the ReadTheDocs API pages because the README stops at installation. Do not adopt it if you need a stable API contract, because pyproject.toml still classifies the project as Development Status 4 - Beta.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 57 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The gap DHG fills between pairwise graphs and beyond-pairwise relations

A graph edge connects exactly two vertices. Many real relations do not. A co-authorship paper connects every author on it at once, a session connects every item a user touched, a chemical reaction connects all its reactants. The usual workaround is to expand the group into a clique of pairwise edges, which changes the object you are modelling and inflates the edge count quadratically with group size.

DHG treats those groups as first-class. The README describes it as a deep learning library built upon PyTorch for learning with both Graph Neural Networks and Hypergraph Neural Networks, and lists the message passing directions it supports: vertex to vertex, vertex in one domain to vertex in another domain, vertex to hyperedge, hyperedge to vertex, and vertex set to vertex set. That last pair, vertex to hyperedge and back, is the part a plain GNN library does not give you.

The audience is narrow and identifiable. If you are reproducing a hypergraph neural network paper, or you have a dataset whose natural unit is a set rather than a pair, DHG gives you the structure and the operators in one place. If you are shipping a recommendation or fraud system on a deadline, the beta classifier and the release history are the more relevant facts.

How DHG organises structures, Laplacians and message passing

The design decision that shapes everything else is stated in the highlights: Laplacian matrices and message passing functions are attached to the graph or hypergraph structure. You build the structure once, and the spectral and spatial operations become methods on it. There is no separate operator registry to keep in sync with your data.

The README separates the two families. Spectral-based operations include Laplacian-based smoothing. Spatial-based operations include message passing from domain to domain. A hypergraph carries both, which is why the same object can serve a spectral convolution layer and a spatial aggregation layer.

DHG also ships conversion in both directions: functions to build a hypergraph from a graph and a graph from a hypergraph. The README frames the upward direction as a possible win, noting that promoting a graph to a hypergraph may exploit high-order connections and improve model performance. Treat that as a hypothesis to test on your data, not a guaranteed improvement; the README does not report a measured gain.

Around the core sit the supporting pieces: random graph and hypergraph generators, public datasets, evaluation metrics, state-of-the-art model implementations, and visualization tools for both low-order and high-order structures. The dhg.experiments module implements Auto-ML on top of Optuna, searching both the structure construction configuration and the model and training hyper-parameters. That is a wider scope than most research libraries attempt, and it explains the dependency list in pyproject.toml, which pulls in optuna, scikit-learn and matplotlib alongside torch and scipy.

Installing DHG and building a first hypergraph

The README states the current stable version is 0.9.7 and gives a single pip command. It does not list a conda channel or a Docker image, so pip is the documented path.

bash
pip install dhg

If you want unreleased code, the README offers the nightly route from the repository. It warns that the nightly version is the development version and may include the latest methods and datasets.

bash
pip install git+https://github.com/iMoonLab/DeepHypergraph.git

On the Python side, pyproject.toml sets requires-python to >=3.8 and classifies support for 3.8 through 3.12. The runtime dependencies are torch>=1.12.1, scipy>=1.8, optuna, numpy, scikit-learn, requests and matplotlib>=3.7.0. Note the torch floor: a CUDA build older than 1.12.1 is outside what the packaging declares.

The README does not include a worked code example, and the install section stops after the two commands. That is a real friction point for a first run. The repository points elsewhere for this: the examples directory contains examples/api_glance.py, examples/node_classification/ and examples/ui_recommender/, and the README links to a tutorials section and an official examples section on ReadTheDocs. Start with api_glance.py, since its name suggests it is the orientation file, then move to the node classification example. Because the README gives no runnable snippet, I am not going to invent one here; the exact constructor signatures belong to the API reference, not to this article.

Where DHG stops being the right tool

The first limitation is packaging maturity. pyproject.toml carries the classifier Development Status :: 4 - Beta. A beta classifier on a library at version 0.9.7, five years after its first release, tells you the maintainers are not promising API stability. Pin your version.

The second is release cadence. The release list shows v0.9.3 in December 2022, v0.9.4 in January 2024, v0.9.5 in September 2025, and the README news announces v0.9.7 on 2026-08-02 with fixes to more than 30 bugs across structure, metrics, models and visualization, plus CI/CD with automated testing and PyPI publishing. There is a long quiet stretch between v0.9.4 and v0.9.5. The last push to the repository was on 2026-08-04. If your project needs frequent upstream fixes, that history is the thing to weigh, not the website.

The third is scope mismatch. DHG is a research library for learning on graph and hypergraph structures. It is not a graph database, and the README does not present it as one. If your problem is storing and querying relations at scale, a graph database is the correct layer and DHG is not a substitute. Similarly, if your data is genuinely pairwise, the hypergraph machinery adds cost without adding expressiveness, and a plain GNN implementation on PyTorch will be easier to debug.

Finally, the documentation boundary. The README is strong on what the library contains and thin on how to drive it end to end. The tutorials and API reference on ReadTheDocs carry that weight. Budget time for reading them before you estimate a task.

DHG against HyperNetX and Hypergraphx

The related searches around this project surface HyperNetX and Hypergraphx, and the comparison is worth making precisely because the three are not the same kind of tool.

HyperNetX is a hypergraph analysis library. Its centre of gravity is structure, incidence, and analysis of the hypergraph itself. DHG's centre of gravity is learning: PyTorch modules, Laplacian-based spectral operations, spatial message passing, convolutional layers, models, metrics and an Optuna-driven experiment module. If your task ends at describing or analysing a hypergraph, DHG is more machinery than you need. If your task ends at a trained model, an analysis library leaves you to write the learning loop yourself.

Hypergraphx sits in the same analysis-oriented family. The same distinction applies: the question is whether you want to compute properties of a hypergraph or train a network on one.

The related searches also include HGNN and general hypergraph neural networks. Those name a model family rather than a competing toolkit, and DHG's role there is as an implementation home: the README states that many state-of-the-art models are implemented and can be used for research. The honest framing is that DHG competes with writing your own PyTorch layers, and its case rests on whether the attached operators, datasets and metrics save you more time than learning its API costs.

Maintenance, licensing and what an upgrade actually costs

The repository is not archived, and the last push was on 2026-08-04. The README news announces v0.9.7 on 2026-08-02, which matches the pyproject.toml version field of 0.9.7, so the packaged version and the announced version agree. The release history is uneven rather than steady, and that is the fact to plan around.

Upgrade cost has two components. The first is the dependency floor. pyproject.toml requires torch>=1.12.1, scipy>=1.8 and matplotlib>=3.7.0, so a DHG upgrade can force a torch upgrade, which in turn can force a CUDA toolchain change on your machine. Check the floor before you bump DHG.

The second is the beta classifier. Because the project does not claim API stability, a minor version bump can rename or reshape a structure class or an operator. Pin dhg to an exact version in your environment file, and read the release notes for the version you are moving to before you move. The v0.9.7 notes describe fixes across structure, metrics, models and visualization, which is broad enough that a silent behaviour change in a metric is plausible.

On licensing, pyproject.toml declares Apache-2.0 and the classifier list includes License :: OSI Approved :: Apache Software License. Apache-2.0 is a permissive licence with an explicit patent grant and requires that you preserve notices and state changes. DHG depends on PyTorch, Optuna, scikit-learn and matplotlib, each under its own terms, so the licence of your combined work depends on the whole set, not on DHG alone. That is a question for your own legal review; nothing here should be read as advice on it.

Editorial conclusion

Adopt DHG if you are doing research that needs hypergraph message passing, spectral operators, or Auto-ML tuning through dhg.experiments on top of Optuna, and you are comfortable reading the ReadTheDocs API pages because the README stops at installation. Do not adopt it if you need a stable API contract, because pyproject.toml still classifies the project as Development Status 4 - Beta. Before committing, verify three things: that pip install dhg resolves to 0.9.7, that your torch version satisfies the torch>=1.12.1 floor, and that the structure class you need appears in the documentation rather than only in the repository tree.

Frequently asked questions

What is the purpose of DeepHypergraph (DHG)?

It is a PyTorch-based deep learning library for learning with graph neural networks and hypergraph neural networks. It provides structures, spectral and spatial operators, models, datasets, metrics and visualization in one framework, plus an Auto-ML module built on Optuna for tuning structure and model hyper-parameters.

What is the difference between a graph and a hypergraph in DeepHypergraph?

DHG supports low-order structures such as graph, directed graph and bipartite graph, and high-order structures such as hypergraph. A graph edge is pairwise, while a hyperedge connects a set of vertices, which is why DHG lists message passing from vertex to hyperedge and from hyperedge to vertex alongside vertex-to-vertex passing.

What does a hypergraph look like in DeepHypergraph?

DHG includes visualization tools for both low-order and high-order structures, so a hypergraph can be rendered rather than only inspected as an incidence matrix. The README does not show a sample rendering, so the visual output is best checked through the documentation and the examples directory.

What is the difference between a multigraph and a hypergraph in DeepHypergraph?

The README does not discuss multigraphs or compare them with hypergraphs, so DHG's documentation does not answer this. What it does state is that hypergraphs are treated as high-order structures with beyond-pairwise message passing, while graph, directed graph and bipartite graph are grouped as low-order structures.

Official sources

  1. iMoonLab/DeepHypergraph on GitHub
  2. License: Apache-2.0
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/imoonlab-deephypergraph.svg)](https://hysenlabs.com/projects/imoonlab-deephypergraph)