Small piece of code in python to compute steady and ranging persistence of features of a hypergraph filtration.
Part of the code (mostly the file persistence.py) is borrowed from the following Generalized Persistence Analysis tool.
The code uses the following python module:
- sys, matplotlib, numpy, math, collections, colorsys;
- HyperNetX for hypergraph handling and visualization;
- tqdm for progress bar (optional).
In this repository, the tests are made with data derived from William Shakespeare’s plays. The data files are stored in the data/ folder and were taken from the Hyperbard dataset.
Here is a great link for plenty of other hypergraph datasets.
To perform the test, go to the repository and call:
python3 test_hyperbard.py filename
with filename being a hyperbard edges.csv file, for instance:
python3 test_hyperbard.py data/king-lear_hg-scene-mw.edges.csv
First, the script will open the hyperbard file to build two hypergraph filtrations: the scene-hypergraph and the character-hypergraph filtrations of the play. The script will plot a sample of this two filtrations (for t=3,5,7,9).
Second, the script will compute four persistence diagrams for each filtrations:
- the steady persistence for the hyperhub feature;
- the ranging persistence for the hyperhub feature;
- the steady(=ranging) persistence for the exclusivity feature;
- the steady(=ranging) persistence for the max originality feature.
Example of steady and ranging persistence for the scene-hypergraph filtration of King Lear:
