HyperNetX

HyperNetX: A Python package for modeling complex network data as hypergraphs - Published in JOSS (2024)

https://github.com/pnnl/hypernetx

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in JOSS metadata
  • Academic publication links
  • Committers with academic emails
    11 of 22 committers (50.0%) from academic institutions
  • Institutional organization owner
    Organization pnnl has institutional domain (www.pnnl.gov)
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

hypergraph hypergraphs knowledge-graph property-hypergraphs python s-linegraph simplicial-complexes simplicial-homology

Keywords from Contributors

mesh

Scientific Fields

Mathematics Computer Science - 84% confidence
Artificial Intelligence and Machine Learning Computer Science - 62% confidence
Last synced: 4 months ago · JSON representation ·

Repository

Python package for hypergraph analysis and visualization.

Basic Info
Statistics
  • Stars: 639
  • Watchers: 19
  • Forks: 104
  • Open Issues: 11
  • Releases: 53
Topics
hypergraph hypergraphs knowledge-graph property-hypergraphs python s-linegraph simplicial-complexes simplicial-homology
Created about 7 years ago · Last pushed 8 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

HyperNetX

Pytest Code style: black linting: pylint CITATION.cff

The HyperNetX (HNX) library provides classes and methods for the analysis and visualization of complex network data modeled as hypergraphs. The library generalizes traditional graph metrics. Documentation for HNX is available at: https://hypernetx.readthedocs.io/

HNX was originally developed by the Pacific Northwest National Laboratory for the Hypernets project as part of its High Performance Data Analytics (HPDA) program. It is currently maintained by scientists at PNNL, but contributions and bug fixes from the community are welcome and encouraged. Please see our Contributor's Guide for more information.

PNNL is operated by Battelle Memorial Institute under Contract DE-ACO5-76RL01830.

  • Principal Developer and Designer: Brenda Praggastis
  • Development Team: Brenda Praggastis, Audun Myers, Greg Roek, Ryan Danehy
  • Visualization: Dustin Arendt, Ji Young Yun
  • Principal Investigator: Cliff Joslyn
  • Program Manager: Brian Kritzstein
  • Principal Contributors (Design, Theory, Code): Sinan Aksoy, Dustin Arendt, Mark Bonicillo, Ryan Danehy, Helen Jenne, Cliff Joslyn, Nicholas Landry, Audun Myers, Christopher Potvin, Brenda Praggastis, Emilie Purvine, Greg Roek, Mirah Shi, Francois Theberge, Ji Young Yun

The code in this repository is intended to support researchers modeling data as hypergraphs. We have a growing community of users and contributors. HNX is a primary contributor to the Hypergraph Interchange Format (HIF), a json schema for sharing data modeled as hypergraphs. The specification and sample notebooks may be found here: https://github.com/pszufe/HIF-standard/tree/main Other hypergraph libraries using this standard are listed below:

For questions and comments about HNX contact the developers directly at: hypernetx@pnnl.gov.

Summary - Release highlights - HNX 2.3

HyperNetX 2.3. is the latest, stable release. The core library has been refactored to take better advantage of Pandas Dataframes, improve readability and maintainability, address bugs, and make it easier to change. New features have been added, most notably the ability to add and remove edges, nodes, and incidences.

Version 2.3 is not backwards compatible. Objects constructed using earlier versions can be imported using their incidence dictionaries and/or property datafames.

What's New

  1. Hypergraph now supports adding and removing edges, nodes, and incidences
  2. Hypergraph also supports the sum, difference, union, and intersection of a Hypergraph to another Hypergraph
  3. New factory methods to support the Hypergraph constructor
  4. EntitySet has been replaced by HypergraphView
  5. IncidenceStore and PropertyStore are new classes that maintain the structure and attributes of a Hypergraph
  6. Hypergraph constructors accept cell, edge, and node metadata.

What's Changed

  1. HNX now requires Python ">=3.10,<4.0.0"
  2. HNX core libraries have been updated
  3. Updated tutorials
  4. The static and dynamic distinctions no longer exist. All hypergraphs use the same underlying data structure, supported by Pandas dataFrames. All hypergraphs maintain a state_dict to avoid repeating computations.
  5. The nwhy optimizations are no longer supported.

Tutorials Available for Colab

Google Colab

Open In Colab Basic 1 - HNX Basics

Open In Colab Basic 2 - Visualization Methods

Open In Colab Basic 3 - LesMis Case Study

Open In Colab Basic 4 - LesMis Visualizations-Book Tour

Open In Colab Basic 5 - HNX attributed hypergraph

Open In Colab Basic 6 - Hypergraph Arithmetic.ipynb

Jupyter Notebooks

Additional tutorials that can be run as Jupyter Notebooks are found under tutorials.

Installation

The recommended installation method for most users is to create a virtual environment and install HyperNetX from PyPi.

HyperNetX may be cloned or forked from GitHub.

Prerequisites

HyperNetX officially supports Python >=3.10,<4.0.0

Create a virtual environment

Using venv

shell python -m venv venv-hnx source venv-hnx/bin/activate

Using Anaconda

shell conda create -n venv-hnx python=3.11 -y conda activate venv-hnx

Using virtualenv

shell virtualenv venv-hnx source venv-hnx/bin/activate

For Windows Users

On both Windows PowerShell or Command Prompt, you can use the following command to activate your virtual environment:

shell .\env-hnx\Scripts\activate

To deactivate your environment, use:

shell .\env-hnx\Scripts\deactivate

Installing HyperNetX

Regardless of how you install HyperNetX, ensure that your environment is activated and that you are running Python ">=3.10,<4.0.0".

Installing from PyPi

shell pip install hypernetx

Installing from Source

Ensure that you have git installed.

```shell git clone https://github.com/pnnl/HyperNetX.git cd HyperNetX

Create a virtual environment

make venv source venv-hnx/bin/activate

install required dependencies

make install ```

Using HyperNetX on Docker

As an alternative to installing HyperNetX, you can use the officially supported HyperNetX Docker image maintained at DockerHub. Use the image to quickly start HyperNetX in a Docker container. The container starts a Jupyter Notebook that has the latest version of HyperNetX and HNXWidget installed; it also contains all the HyperNetX tutorials.

Run the Container

  • Using Docker CLI, run the container in the foreground:

docker run -it --rm -p 8888:8888 -v "${PWD}":/home/jovyan/work hypernetx/hypernetx:latest

  • Alternatively, you can create a docker-compose.yml file with the following: ``` version: '3'

services: hypernetx: image: hypernetx/hypernetx:latest ports: - "8888:8888" tty: true stdin_open: true volumes: - "${PWD}:/home/jovyan/work" ```

Once docker-compose.yml is created, run the container:

docker-compose up

Open Jupyter Notebook

After the container has started, access the HyperNetX Jupyter Notebooks by opening the following URL in a browser:

http://localhost:8888/tree

Development

As a developer, set up your environment using either the standard pip tool or Poetry.

Using Pip

Setup virtual environment and install HNX

Create a virtual environement. Then install an editable version of HNX and also install additional dependencies to support testing and jupyter notebooks: python -m venv venv-hnx source venv-hnx/bin/activate pip install -e . pip install -r requirements.txt

As an alternative, you can also install all these requirements in one Make target:

make venv source venv-hnx/bin/activate make install

Setup pre-commit

Use the pre-commit framework to automatically point out issues and resolve those issues before code review. It is highly recommended to install pre-commit in your development environment so that issues with your code can be found before you submit a pull request. More importantly, using pre-commit will automatically format your code changes so that they pass the CI build. For example, pre-commit will automatically run the formatter Black on your code changes.

```shell

Once installed, pre-commit will be triggered every time you make a commit in your environment

pre-commit install ```

Using Poetry

This library uses Poetry to manage dependencies and packaging. Poetry can also be used to manage your environment for development.

Prerequisites

Configure Poetry

Configure your Poetry to ensure that the virtual environment gets created in your project directory (this is not necessary but recommended for convenience):

``` poetry config virtualenvs.in-project true

check the poetry configuration

poetry config --list ```

Setup virtual environment and install HNX

Create and activate a virtual environment.

poetry shell

Install HyperNetX in editable mode, the library's core/required dependencies, and the optional dependencies to support development.

poetry install --with test,lint,docs,release,tutorials

Details about these dependencies are defined in pyproject.toml.

Setup Pre-commit

Use the pre-commit framework to automatically point out issues and resolve those issues before code review. It is highly recommended to install pre-commit in your development environment so that issues with your code can be found before you submit a pull request. More importantly, using pre-commit will automatically format your code changes so that they pass the CI build. For example, pre-commit will automatically run the formatter Black on your code changes.

```shell

Once installed, pre-commit will be triggered every time you make a commit in your environment

pre-commit install ```

Details about optional dependencies

Install support for testing

ℹ️ NOTE: This project has pytest configuration contained in pyproject.toml. By default, pytest will use those configuration settings to run tests.

```shell poetry install --with test

activate your virtual environment created by poetry

poetry shell

run tests

python -m pytest

run tests and show coverage report

python -m pytest --cov=hypernetx

Generate an HTML code coverage report and view it on a browser

coverage html open htmlcov/index.html ```

Install support for tutorials

```shell poetry install --with tutorials

activate your virtual environment created by poetry

poetry shell

open Jupyter notebooks in a browser

make tutorials ```

Code Quality: Pylint, Black

HyperNetX uses a number of tools to maintain code quality:

  • Pylint
  • Black

Before using these tools, ensure that you install Pylint in your environment:

```shell poetry install --with lint

activate your virtual environment created by poetry

poetry shell ```

Pylint is a static code analyzer for Python-based projects. From the Pylint docs:

Pylint analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored. Pylint can infer actual values from your code using its internal code representation (astroid). If your code is import logging as argparse, Pylint will know that argparse.error(...) is in fact a logging call and not an argparse call.

To run Pylint and view the results of Pylint, run the following command:

shell pylint hypernetx

You can also run Pylint on the command line to generate a report on the quality of the codebase and save it to a file named "pylint-results.txt":

shell pylint hypernetx --output=pylint-results.txt

For more information on configuration, see https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html

Black is a PEP 8 compliant formatter for Python-based project. This tool is highly opinionated about how Python should be formatted and will automagically reformat your code.

shell black hypernetx

Documentation

Build and view documentation locally:

```shell poetry install --with docs

activate your virtual environment created by poetry

poetry shell

cd docs make html open docs/build/html/index.html ```

When editing documentation, you can auto-rebuild the documentation locally so that you can view your document changes live on the browser without having to rebuild every time you have a change.

shell cd docs make livehtml

This make script will run in the foreground on your terminal. You should see the following:

shell The HTML pages are in docs/html. [I 230324 09:50:48 server:335] Serving on http://127.0.0.1:8000 [I 230324 09:50:48 handlers:62] Start watching changes [I 230324 09:50:48 handlers:64] Start detecting changes [I 230324 09:50:54 handlers:135] Browser Connected: http://127.0.0.1:8000/install.html [I 230324 09:51:02 handlers:135] Browser Connected: http://127.0.0.1:8000/

Click on http://127.0.0.1:8000/install.html to open the docs on your browser. Since this will auto-rebuild, every time you change a document file, it will automatically render on your browser, allowing you to verify your document changes.

Developing and Testing the Docker Image

If you want to test the Docker image after making any source code changes, follow this workflow:

  1. Make a change in the HNX codebase
  2. Build image for multi-platforms (i.e.ARM64, x86): docker build --platform linux/amd64,linux/arm64 --rm --tag hypernetx/hypernetx:latest .
    1. If you're having issues building, see https://docs.docker.com/desktop/containerd/
  3. Test image: docker run -it --rm -p 8888:8888 -v "${PWD}":/home/jovyan/work hypernetx/hypernetx:latest
  4. Open a browser to http://localhost:8888/tree. Check that tutorials still work and/or open a notebook and test the changes that you made.
  5. Once finished testing, kill the container using Ctrl-C

Notice

This material was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of their employees, nor any jurisdiction or organization that has cooperated in the development of these materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.

    PACIFIC NORTHWEST NATIONAL LABORATORY
    operated by
    BATTELLE
    for the
    UNITED STATES DEPARTMENT OF ENERGY
    under Contract DE-AC05-76RL01830
  

License

Released under the 3-Clause BSD license

Owner

  • Name: Pacific Northwest National Laboratory (Public)
  • Login: pnnl
  • Kind: organization
  • Email: dev-central@pnnl.gov
  • Location: United States of America

This Org is intended for the hosting of approved released PNNL software repositories for public use and collaboration.

JOSS Publication

HyperNetX: A Python package for modeling complex network data as hypergraphs
Published
March 09, 2024
Volume 9, Issue 95, Page 6016
Authors
Brenda Praggastis ORCID
Pacific Northwest National Laboratory, USA
Sinan Aksoy ORCID
Pacific Northwest National Laboratory, USA
Dustin Arendt ORCID
Pacific Northwest National Laboratory, USA
Mark Bonicillo ORCID
Pacific Northwest National Laboratory, USA
Cliff Joslyn ORCID
Pacific Northwest National Laboratory, USA
Emilie Purvine ORCID
Pacific Northwest National Laboratory, USA
Madelyn Shapiro ORCID
Pacific Northwest National Laboratory, USA
Ji Young Yun
Pacific Northwest National Laboratory, USA
Editor
Daniel S. Katz ORCID
Tags
hypergraph network science simplicial-complexes knowledge graph simplicial-homology s-linegraph property hypergraph

Citation (CITATION.cff)

cff-version: "1.2.0"
authors:
- family-names: Praggastis
  given-names: Brenda
  orcid: "https://orcid.org/0000-0003-1344-0497"
- family-names: Aksoy
  given-names: Sinan
  orcid: "https://orcid.org/0000-0002-3466-3334"
- family-names: Arendt
  given-names: Dustin
  orcid: "https://orcid.org/0000-0003-2466-199X"
- family-names: Bonicillo
  given-names: Mark
  orcid: "https://orcid.org/0009-0003-9764-2180"
- family-names: Joslyn
  given-names: Cliff
  orcid: "https://orcid.org/0000-0002-5923-5547"
- family-names: Purvine
  given-names: Emilie
  orcid: "https://orcid.org/0000-0003-2069-5594"
- family-names: Shapiro
  given-names: Madelyn
  orcid: "https://orcid.org/0000-0002-2786-7056"
- family-names: Yun
  given-names: Ji Young
doi: 10.5281/zenodo.10795225
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Praggastis
    given-names: Brenda
    orcid: "https://orcid.org/0000-0003-1344-0497"
  - family-names: Aksoy
    given-names: Sinan
    orcid: "https://orcid.org/0000-0002-3466-3334"
  - family-names: Arendt
    given-names: Dustin
    orcid: "https://orcid.org/0000-0003-2466-199X"
  - family-names: Bonicillo
    given-names: Mark
    orcid: "https://orcid.org/0009-0003-9764-2180"
  - family-names: Joslyn
    given-names: Cliff
    orcid: "https://orcid.org/0000-0002-5923-5547"
  - family-names: Purvine
    given-names: Emilie
    orcid: "https://orcid.org/0000-0003-2069-5594"
  - family-names: Shapiro
    given-names: Madelyn
    orcid: "https://orcid.org/0000-0002-2786-7056"
  - family-names: Yun
    given-names: Ji Young
  date-published: 2024-03-09
  doi: 10.21105/joss.06016
  issn: 2475-9066
  issue: 95
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 6016
  title: "HyperNetX: A Python package for modeling complex network data
    as hypergraphs"
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.06016"
  volume: 9
title: "HyperNetX: A Python package for modeling complex network data as
  hypergraphs"

GitHub Events

Total
  • Create event: 8
  • Release event: 8
  • Issues event: 11
  • Watch event: 81
  • Issue comment event: 10
  • Push event: 10
  • Pull request event: 2
  • Fork event: 11
Last Year
  • Create event: 8
  • Release event: 8
  • Issues event: 11
  • Watch event: 81
  • Issue comment event: 10
  • Push event: 10
  • Pull request event: 2
  • Fork event: 11

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,335
  • Total Committers: 22
  • Avg Commits per committer: 60.682
  • Development Distribution Score (DDS): 0.551
Past Year
  • Commits: 120
  • Committers: 6
  • Avg Commits per committer: 20.0
  • Development Distribution Score (DDS): 0.6
Top Committers
Name Email Commits
Brenda Praggastis b****s@p****v 599
Mark Bonicillo m****o@p****v 342
Madelyn Shapiro m****o@p****v 126
Dustin Arendt d****t@p****v 72
Nicholas Landry n****y@p****v 37
audun myers a****s@g****m 34
Ji Young Yun j****n@.****v 27
Noah Farris n****s@p****v 27
ryan.danehy@pnnl.gov d****8@w****v 25
Francois Theberge f****s@M****l 21
Myers, Audun D a****s@p****v 7
Bittner, Alyson S a****r@p****v 5
dependabot[bot] 4****] 2
Roek, Gregory H g****k@p****v 2
Brenda Praggastis 3****l 2
Aric Hagberg a****b@g****m 1
Francois f****s@F****l 1
Sinan Aksoy s****y@p****v 1
Szabolcs Horvát s****t@g****m 1
bpraggastis b****s 1
dialecticDolt w****s@g****m 1
nicol n****8@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 68
  • Total pull requests: 89
  • Average time to close issues: 5 months
  • Average time to close pull requests: 9 days
  • Total issue authors: 45
  • Total pull request authors: 16
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.49
  • Merged pull requests: 63
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 6
  • Pull requests: 2
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 16 hours
  • Issue authors: 5
  • Pull request authors: 1
  • Average comments per issue: 1.33
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • szhorvat (12)
  • drj11 (7)
  • michaeldorner (3)
  • epideveloper (2)
  • gl-yziquel (2)
  • q923397935 (2)
  • LucaGherardini (2)
  • jim-rafferty (1)
  • zhangshea (1)
  • impredicative (1)
  • pharaon-dev (1)
  • mr1ck7 (1)
  • colltoaction (1)
  • RemiG3 (1)
  • yizhihenpidehou (1)
Pull Request Authors
  • brendapraggastis (58)
  • bonicim (12)
  • dependabot[bot] (5)
  • ftheberge (3)
  • RaphaelPellegrin (2)
  • LilithHafner (2)
  • ryandanehy (2)
  • jim-rafferty (2)
  • dlarendt (2)
  • wlruys (2)
  • danielskatz (2)
  • roman-timo (1)
  • szhorvat (1)
  • uninicol (1)
  • rotshira (1)
Top Labels
Issue Labels
active (16) joss (15) backlog (6) enhancement (4) bug (3)
Pull Request Labels
dependencies (5)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 8,902 last-month
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 9
    (may contain duplicates)
  • Total versions: 67
  • Total maintainers: 4
pypi.org: hypernetx

HyperNetX is a Python library for the creation and study of hypergraphs.

  • Versions: 50
  • Dependent Packages: 3
  • Dependent Repositories: 8
  • Downloads: 8,672 Last month
Rankings
Dependent packages count: 3.2%
Stargazers count: 3.2%
Average: 4.3%
Downloads: 4.9%
Forks count: 5.0%
Dependent repos count: 5.2%
Maintainers (3)
Last synced: 4 months ago
pypi.org: hnxbeta

HyperNetX is a Python library for the creation and study of hypergraphs.

  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 230 Last month
Rankings
Stargazers count: 3.2%
Forks count: 5.0%
Dependent packages count: 10.1%
Average: 12.8%
Dependent repos count: 21.6%
Downloads: 24.3%
Maintainers (3)
Last synced: about 1 year ago

Dependencies

setup.py pypi
  • celluloid >=0.2.0
  • matplotlib >3.0
  • networkx >=2.2,<3.0
  • numpy >=1.15.0,<2.0
  • pandas >=0.23
  • python-igraph >=0.9.6
  • scikit-learn >=0.20.0
  • scipy >=1.1.0,<2.0
.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pre-commit/action v3.0.0 composite
.github/workflows/documentation.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/publish-to-pypi.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
pyproject.toml pypi