This repository contains implementations of the top-k hyperedge triplet retrieval algorithm from this paper.
If you use this code, please cite
@article{niu2023size, title={Size-Aware Hypergraph Motifs}, author={Niu, Jason and Amburg, Ilya D and Aksoy, Sinan G and Sar{\i}y{"u}ce, Ahmet Erdem}, journal={arXiv preprint arXiv:2311.07783}, year={2023} }
There are three implementations: (1) HyperNetX, (2) standalone Python, and (3) C++ with a Python wrapper. Each implementation has a Jupyter notebook tutorial.
The HyperNetX folder contains code that will be embeded in the hypergraph analytics library HyperNetX (hnx). Steps to add max_triplet to HyperNetX:
(1) Clone HyperNetX from https://github.com/pnnl/HyperNetX. - We refer to this as HyperNetX-master
(2) Add max_triplet.py to HyperNetX-master/hypernetx/algorithms
(3) Add from .max_triplet import * to HyperNetX-master/hypernetx/algorithms/init.py
(4) Add test_max_triplet.py to HyperNetX-master/hypernetx/algorithms/tests
(5) Add Tutorial 14 - Maximum Hyperedge Triplets.ipynb to HyperNetX-master/tutorials - Change Tutorial 14 to a later number if necessary
(6) Add images/ShadedTriplet.png to HyperNetX-master/tutorials/images
The python_standalone folder contains code that you could run independently of HyperNetX.
The python_wrapper folder contains code in C++ with a Python wrapper. This is the fastest implementation.
Portable memory mapping class from https://github.com/stbrumme/portable-memory-mapping.
Parallel hashmap from https://github.com/greg7mdp/parallel-hashmap.
This code contains a Python wrapper built on top of C++ and was tested using Python 3.8.10 and GCC 7.3.0. Tested on Linux and Windows operating systems.
To use the Python wrapper, we first need to compile the C++ code into a shared library as follows:
1) g++ -fPIC -shared -o max_triplet.so max_triplet.cpp portable-memory-mapping-master/MemoryMapped.cpp -std=c++17 -O3
Make sure the shared library max_triplet.so is in the same directory as your code which imports the python wrapper. An example of how to run the code is in max_triplet.ipynb.
Dataset format:
|E| |U| |V|
u1 v1
u2 v1
u2 v2
Example dataset:
3 2 2
0 0
0 1
1 0