This repository contains a Python package that provides the following code:
- 🔥 PyTorch implementation of Janus $\beta\text{-VAE}$ and Janus DDM;
- ⚡️ Janus-* training script using PyTorch Lightning;
- 👨💻 Hypergraph Analysis script to compare generated vs target dataset hypergraphs;
- 📄 Results report script to construct table and charts from generation results;
- ⌨️ A simple command line interface that can be used to launch training and sampling scripts.
Setup
pip install git+https://github.com/anonymous-author-1234/Janus
Requirements. Additionally to the code provided in this repository, you should install torch and lightning.
Training
janus [DATASET] <OPTIONS> train <OPTIONS> bvae <OPTIONS> --vertex-encoding/--no-vertex-encoding
and then
janus [DATASET] train <OPTIONS> ddm <OPTIONS> --bvae-ckpt
Model size
The size of both $\beta\text{-VAE}$ and DDM can be set using the --model-size option of the janus train command. The following models sizes are available.
| Size | # Layers | # Heads | Hidden size |
| S | 1 | 2 | 128 |
| M | 2 | 4 | 256 |
| Size | # Layers | # Heads | Hidden size |
| S | 2 | 4 | 256 |
| M | 3 | 8 | 512 |
Model hyperparameters
We trained both models fixing the following hyperparameters.
- Shared Hyperparameters
- batch size 32
- samples per hyperedge 2
- biased random walk p 2.0
- biased random walk q 0.5
- $\beta\text{-VAE}$
- patience 100
- DDM
- training timesteps 1000
The learning rate is determined using a learning rate finder strategy.
Analysis

janus-stats analysis <OPTIONS>
Compare
First of all you need to download the datasets and analyze them:
janus-stats parse [DATASET_NAME]
janus-stats analyze --root-dir references
At this point, you can perform analysis over all hypergraphs in the samples/ directory:
janus-stats analyze
Finally, run the comparison script to compare each sample with its relative reference.
janus-stats compare
Reproducibility
Training
In order to run the training configuration we used in our paper, run the following commands to train both models:
janus --batch-size 32 [DATASET] train --model-size S bvae
janus --batch-size 32 --val-size 0 [DATASET] train --model-size S --samples-per-hyperedge 2 ddm --bvae-ckpt logs/[DATASET]/BVAE-Janus-S/logs/version_0/checkpoints/best.ckpt
Sampling
janus --batch-size 32 [DATASET] sample --ckpt logs/[DATASET]/logs/version_0/DDM-Janus-S/checkpoints/last.ckpt ddm
Datasets
| Dataset | # Nodes | # Hyperedges | # Connected Components | LCC Ratio |
| anonymous-author-1234/email-Enron | 143 | 1,512 | 1 | 1 |
| anonymous-author-1234/email-Eu | 998 | 25,791 | 20 | 0.9809619238476954 |
| anonymous-author-1234/contact-high-school | 327 | 7,937 | 1 | 1 |
| anonymous-author-1234/contact-primary-school | 242 | 12,799 | 1 | 1 |
| anonymous-author-1234/NDC-classes | 1,161 | 1,222 | 183 | 0.540913006029285 |
Dataset structure
data/ full-00000-of-00001.jsonl
When running the training script full is the default split for train/val/predict (the predict split is only used when performing sampling from the $\beta\text{-VAE}$).
If the split is equal for train/val, the --val-size option is used to perform train/val split across that dataset, otherwise this option is ignored.
janus anonymous-author-1234/email-Enron train --train-split train --val-split val --predict-split predict bvae
Use different datasets
Our pipeline is able to handle single and multi-hypergraph datasets retrieved from huggingface.
In order to work, an hypergraph dataset must be stored in a .jsonl file, where each entry is a JSON following the HIF standard:
{
"network-type": ...,
"metadata": ...,
"incidences": [...],
"nodes": [...],
"edges": [...]
}
In order to provide nodes and edges features, these must be set in the attrs dictionary of each node/edge.
Experiments Summary
| Model/Dataset | email-Enron | email-Eu | NDC-classes | contact-high-school | contact-primary-school |
| BVAE | X | X | X | X | X |
| DDM | X | / | X | X | X |
| BVAE-V | X | / | X | X | X |
| DDM-V | - | - | - | - | - |