{"id":21678073,"url":"https://github.com/pnnl/hypernetx","last_synced_at":"2025-05-14T12:12:14.853Z","repository":{"id":40523722,"uuid":"154165172","full_name":"pnnl/HyperNetX","owner":"pnnl","description":"Python package for hypergraph analysis and visualization.","archived":false,"fork":false,"pushed_at":"2025-04-17T01:58:39.000Z","size":264360,"stargazers_count":610,"open_issues_count":11,"forks_count":101,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-14T02:48:15.254Z","etag":null,"topics":["hypergraph","hypergraphs","knowledge-graph","property-hypergraphs","python","s-linegraph","simplicial-complexes","simplicial-homology"],"latest_commit_sha":null,"homepage":"https://hypernetx.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pnnl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.rst","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-22T15:10:44.000Z","updated_at":"2025-05-12T08:45:19.000Z","dependencies_parsed_at":"2023-10-10T20:47:16.976Z","dependency_job_id":"69cf9d9e-0662-449e-8c74-504b0103cdef","html_url":"https://github.com/pnnl/HyperNetX","commit_stats":{"total_commits":478,"total_committers":14,"mean_commits":"34.142857142857146","dds":"0.32845188284518834","last_synced_commit":"5e119683668429bb5321b1a2bf61b93996821b11"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnnl%2FHyperNetX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnnl%2FHyperNetX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnnl%2FHyperNetX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnnl%2FHyperNetX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pnnl","download_url":"https://codeload.github.com/pnnl/HyperNetX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140768,"owners_count":22021220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hypergraph","hypergraphs","knowledge-graph","property-hypergraphs","python","s-linegraph","simplicial-complexes","simplicial-homology"],"created_at":"2024-11-25T14:25:52.939Z","updated_at":"2025-05-14T12:12:14.828Z","avatar_url":"https://github.com/pnnl.png","language":"Python","readme":"HyperNetX\n==========\n\n\u003cimg src=\"https://raw.githubusercontent.com/pnnl/HyperNetX/master/docs/source/images/harrypotter_basic_hyp.png\" align=\"right\" width=\"300pt\"\u003e\n\n[![Pytest](https://github.com/pnnl/HyperNetX/actions/workflows/ci.yml/badge.svg)](https://github.com/pnnl/HyperNetX/actions/workflows/ci.yml)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)\n[![CITATION.cff](https://github.com/pnnl/HyperNetX/actions/workflows/cff.yml/badge.svg)](https://github.com/pnnl/HyperNetX/actions/workflows/cff.yml)\n\nThe HyperNetX (HNX) library provides classes and methods for the analysis\nand visualization of complex network data modeled as hypergraphs.\nThe library generalizes traditional graph metrics.\nDocumentation for HNX is available at: https://hypernetx.readthedocs.io/\n\nHNX was originally developed by the Pacific Northwest National Laboratory for the\nHypernets project as part of its High Performance Data Analytics (HPDA) program.\nIt is currently maintained by scientists at PNNL, but contributions and bug fixes\nfrom the community are welcome and encouraged.\nPlease see our [Contributor's Guide](https://hypernetx.readthedocs.io/en/latest/contributions.html)\nfor more information.\n\nPNNL is operated by Battelle Memorial Institute under Contract DE-ACO5-76RL01830.\n\n* Principal Developer and Designer: Brenda Praggastis\n* Development Team: Brenda Praggastis, Audun Myers, Greg Roek, Ryan Danehy\n* Visualization: Dustin Arendt, Ji Young Yun\n* Principal Investigator: Cliff Joslyn\n* Program Manager: Brian Kritzstein\n* 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\n\nThe code in this repository is intended to support researchers modeling data\nas hypergraphs. We have a growing community of users and contributors.\nHNX is a primary contributor to the\nHypergraph Interchange Format (HIF), a json schema for sharing data\nmodeled as hypergraphs. The specification and sample notebooks may be found\nhere: https://github.com/pszufe/HIF-standard/tree/main\nOther hypergraph libraries using this standard are listed below:\n\n- [HypergraphX (HGX)](https://github.com/HGX-Team/hypergraphx) (Python)\n- [CompleX Group Interactions (XGI)](https://github.com/xgi-org/xgi) (Python)\n- [SimpleHypergraphs.jl](https://github.com/pszufe/SimpleHypergraphs.jl) (Julia)\n- [Hypergraph-Analysis-Toolbox(HAT)](https://github.com/Jpickard1/Hypergraph-Analysis-Toolbox) (Python)\n\nFor questions and comments about HNX contact the developers directly at: hypernetx@pnnl.gov.\n\nSummary - Release highlights - HNX 2.3\n--------------------------------------\n\nHyperNetX 2.3. is the latest, stable release. The core library has been refactored to take better advantage\nof Pandas Dataframes, improve readability and maintainability, address bugs, and make it easier to change.\nNew features have been added, most notably the ability to add and remove edges, nodes, and incidences.\n\n**Version 2.3 is not backwards compatible. Objects constructed using earlier versions\ncan be imported using their incidence dictionaries and/or property datafames.**\n\nWhat's New\n----------\n1. Hypergraph now supports adding and removing edges, nodes, and incidences\n1. Hypergraph also supports the sum, difference, union, and intersection of a Hypergraph to another Hypergraph\n1. New factory methods to support the Hypergraph constructor\n1. EntitySet has been replaced by HypergraphView\n1. IncidenceStore and PropertyStore are new classes that maintain the structure and attributes of a Hypergraph\n1. Hypergraph constructors accept cell, edge, and node metadata.\n\n\nWhat's Changed\n--------------\n1. HNX now requires Python \"\u003e=3.10,\u003c4.0.0\"\n1. HNX core libraries have been updated\n1. Updated tutorials\n1. 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.\n1. The `nwhy` optimizations are no longer supported.\n\n\nTutorials Available for Colab\n=============================\n\nGoogle Colab\n------------\n\n\n\u003ca href=\"https://colab.research.google.com/github/pnnl/HyperNetX/blob/master/tutorials/basic/Basic%201%20-%20HNX%20Basics.ipynb\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\n    \u003cspan \u003eBasic 1 - HNX Basics\u003c/span\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\n\u003ca href=\"https://colab.research.google.com/github/pnnl/HyperNetX/blob/master/tutorials/basic/Basic%202%20-%20Visualization%20Methods.ipynb\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\n    \u003cspan \u003eBasic 2 - Visualization Methods\u003c/span\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\n\u003ca href=\"https://colab.research.google.com/github/pnnl/HyperNetX/blob/master/tutorials/basic/Basic%203%20-%20LesMis%20Case%20Study.ipynb\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\n    \u003cspan \u003eBasic 3 - LesMis Case Study\u003c/span\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\n\u003ca href=\"https://colab.research.google.com/github/pnnl/HyperNetX/blob/master/tutorials/basic/Basic%204%20-%20LesMis%20Visualizations-BookTour.ipynb\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\n    \u003cspan \u003eBasic 4 - LesMis Visualizations-Book Tour\u003c/span\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\n\u003ca href=\"https://colab.research.google.com/github/pnnl/HyperNetX/blob/master/tutorials/basic/Basic%205%20-%20HNX%20attributed%20hypergraph.ipynb\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\n    \u003cspan \u003eBasic 5 - HNX attributed hypergraph\u003c/span\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\n\u003ca href=\"https://colab.research.google.com/github/pnnl/HyperNetX/blob/master/tutorials/basic/Basic%206%20-%20Hypergraph%20Arithmetic.ipynb\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\n    \u003cspan \u003eBasic 6 - Hypergraph Arithmetic.ipynb\u003c/span\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\n\nJupyter Notebooks\n-----------------\n\nAdditional tutorials that can be run as Jupyter Notebooks are found under [tutorials](./tutorials).\n\nInstallation\n====================\n\nThe recommended installation method for most users is to create a virtual environment and install HyperNetX from PyPi.\n\nHyperNetX may be cloned or forked from [GitHub](https://github.com/pnnl/HyperNetX).\n\nPrerequisites\n-------------\nHyperNetX officially supports Python \u003e=3.10,\u003c4.0.0\n\nCreate a virtual environment\n----------------------------\n\n### Using venv\n\n\n```shell\npython -m venv venv-hnx\nsource venv-hnx/bin/activate\n```\n\n\n### Using Anaconda\n\n\n```shell\nconda create -n venv-hnx python=3.11 -y\nconda activate venv-hnx\n```\n\n\n### Using virtualenv\n\n\n```shell\nvirtualenv venv-hnx\nsource venv-hnx/bin/activate\n```\n\n\n### For Windows Users\n\nOn both Windows PowerShell or Command Prompt, you can use the following command to activate your virtual environment:\n\n```shell\n.\\env-hnx\\Scripts\\activate\n```\n\nTo deactivate your environment, use:\n\n```shell\n.\\env-hnx\\Scripts\\deactivate\n```\n\nInstalling HyperNetX\n====================\n\nRegardless of how you install HyperNetX, ensure that your environment is activated and that you are running Python \"\u003e=3.10,\u003c4.0.0\".\n\n\nInstalling from PyPi\n--------------------\n\n```shell\npip install hypernetx\n```\n\nInstalling from Source\n----------------------\n\nEnsure that you have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) installed.\n\n```shell\ngit clone https://github.com/pnnl/HyperNetX.git\ncd HyperNetX\n\n# Create a virtual environment\nmake venv\nsource venv-hnx/bin/activate\n\n# install required dependencies\nmake install\n```\n\n# Using HyperNetX on Docker\n\nAs an alternative to installing HyperNetX, you can use the officially supported HyperNetX Docker image maintained at\n[DockerHub](https://hub.docker.com/r/hypernetx/hypernetx). Use the image to quickly start HyperNetX in a Docker container.\nThe container starts a Jupyter Notebook that has the latest version of HyperNetX and HNXWidget installed;\nit also contains all the HyperNetX tutorials.\n\n## Run the Container\n\n* Using Docker CLI, run the container in the foreground:\n\n```\ndocker run -it --rm -p 8888:8888 -v \"${PWD}\":/home/jovyan/work hypernetx/hypernetx:latest\n```\n\n* Alternatively, you can create a `docker-compose.yml` file with the following:\n```\nversion: '3'\n\nservices:\n  hypernetx:\n    image: hypernetx/hypernetx:latest\n    ports:\n      - \"8888:8888\"\n    tty: true\n    stdin_open: true\n    volumes:\n      - \"${PWD}:/home/jovyan/work\"\n```\n\nOnce `docker-compose.yml` is created, run the container:\n\n```\ndocker-compose up\n```\n\n## Open Jupyter Notebook\n\nAfter the container has started, access the HyperNetX Jupyter Notebooks by opening the following URL in a browser:\n\n[http://localhost:8888/tree](http://localhost:8888/tree)\n\n\n# Development\n\nAs a developer, set up your environment using either the standard `pip` tool or [`Poetry`](https://python-poetry.org/).\n\n## Using Pip\n\n### Setup virtual environment and install HNX\n\nCreate a virtual environement. Then install an editable version of HNX and also install additional dependencies to support testing and jupyter notebooks:\n```\npython -m venv venv-hnx\nsource venv-hnx/bin/activate\npip install -e .\npip install -r requirements.txt\n```\n\nAs an alternative, you can also install all these requirements in one Make target:\n\n```\nmake venv\nsource venv-hnx/bin/activate\nmake install\n```\n\n### Setup pre-commit\n\nUse the [pre-commit framework](https://pre-commit.com/) to automatically point out issues and resolve those issues before code review.\nIt is highly recommended to install pre-commit in your development environment so that issues with your code can be found before you submit a\npull request. More importantly, using pre-commit will automatically format your code changes so that they pass the CI build. For example, pre-commit will\nautomatically run the formatter Black on your code changes.\n\n```shell\n# Once installed, pre-commit will be triggered every time you make a commit in your environment\npre-commit install\n```\n\n\n## Using Poetry\n\nThis library uses [Poetry](https://python-poetry.org/docs/) to manage dependencies and packaging. Poetry can also be\nused to manage your environment for development.\n\n### Prerequisites\n\n* [Install Poetry](https://python-poetry.org/docs/#installation)\n\n\n### Configure Poetry\n\n[Configure your Poetry](https://python-poetry.org/docs/configuration/) to ensure that the virtual environment gets created in your project directory (this is not necessary but recommended for convenience):\n\n```\npoetry config virtualenvs.in-project true\n\n# check the poetry configuration\npoetry config --list\n```\n\n### Setup virtual environment and install HNX\n\nCreate and activate a virtual environment.\n\n```\npoetry shell\n```\n\nInstall HyperNetX in editable mode, the library's core/required dependencies, and the optional dependencies to support development.\n\n```\npoetry install --with test,lint,docs,release,tutorials\n```\n\nDetails about these dependencies are defined in [pyproject.toml](pyproject.toml).\n\n### Setup Pre-commit\n\nUse the [pre-commit framework](https://pre-commit.com/) to automatically point out issues and resolve those issues before code review.\nIt is highly recommended to install pre-commit in your development environment so that issues with your code can be found before you submit a\npull request. More importantly, using pre-commit will automatically format your code changes so that they pass the CI build. For example, pre-commit will\nautomatically run the formatter Black on your code changes.\n\n```shell\n# Once installed, pre-commit will be triggered every time you make a commit in your environment\npre-commit install\n```\n\n### Details about optional dependencies\n\n#### Install support for testing\n\n\n\u003e ℹ️ **NOTE:** This project has pytest configuration contained in pyproject.toml. By default, pytest will use those configuration settings to run tests.\n\n```shell\npoetry install --with test\n\n# activate your virtual environment created by poetry\npoetry shell\n\n# run tests\npython -m pytest\n\n# run tests and show coverage report\npython -m pytest --cov=hypernetx\n\n# Generate an HTML code coverage report and view it on a browser\ncoverage html\nopen htmlcov/index.html\n```\n\n#### Install support for tutorials\n\n```shell\npoetry install --with tutorials\n\n# activate your virtual environment created by poetry\npoetry shell\n\n# open Jupyter notebooks in a browser\nmake tutorials\n```\n\n#### Code Quality: Pylint, Black\n\nHyperNetX uses a number of tools to maintain code quality:\n\n* Pylint\n* Black\n\nBefore using these tools, ensure that you install Pylint in your environment:\n\n```shell\npoetry install --with lint\n\n# activate your virtual environment created by poetry\npoetry shell\n```\n\n\n[Pylint](https://pylint.pycqa.org/en/latest/index.html) is a static code analyzer for Python-based projects. From the [Pylint docs](https://pylint.pycqa.org/en/latest/index.html#what-is-pylint):\n\n\u003e 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.\n\nTo run Pylint and view the results of Pylint, run the following command:\n\n```shell\npylint hypernetx\n```\n\nYou 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\":\n\n```shell\npylint hypernetx --output=pylint-results.txt\n```\n\nFor more information on configuration, see https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html\n\n[Black](https://black.readthedocs.io/en/stable/) 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.\n\n\n```shell\nblack hypernetx\n```\n\n### Documentation\n\nBuild and view documentation locally:\n\n```shell\npoetry install --with docs\n\n# activate your virtual environment created by poetry\npoetry shell\n\ncd docs\nmake html\nopen docs/build/html/index.html\n```\n\nWhen editing documentation, you can auto-rebuild the documentation locally so that you can view your document changes\nlive on the browser without having to rebuild every time you have a change.\n\n```shell\ncd docs\nmake livehtml\n```\n\nThis make script will run in the foreground on your terminal. You should see the following:\n\n```shell\nThe HTML pages are in docs/html.\n[I 230324 09:50:48 server:335] Serving on http://127.0.0.1:8000\n[I 230324 09:50:48 handlers:62] Start watching changes\n[I 230324 09:50:48 handlers:64] Start detecting changes\n[I 230324 09:50:54 handlers:135] Browser Connected: http://127.0.0.1:8000/install.html\n[I 230324 09:51:02 handlers:135] Browser Connected: http://127.0.0.1:8000/\n```\n\nClick on [http://127.0.0.1:8000/install.html](http://127.0.0.1:8000/install.html) to open the docs on your browser. Since this will auto-rebuild, every time\nyou change a document file, it will automatically render on your browser, allowing you to verify your document changes.\n\n\n## Developing and Testing the Docker Image\n\nIf you want to test the Docker image after making any source code changes, follow this workflow:\n\n1. Make a change in the HNX codebase\n2. Build image for multi-platforms (i.e.ARM64, x86): `docker build --platform linux/amd64,linux/arm64 --rm --tag hypernetx/hypernetx:latest .`\n   3. If you're having issues building, see https://docs.docker.com/desktop/containerd/\n3. Test image: `docker run -it --rm -p 8888:8888 -v \"${PWD}\":/home/jovyan/work hypernetx/hypernetx:latest`\n4. Open a browser to [http://localhost:8888/tree](http://localhost:8888/tree). Check that tutorials still work and/or open a notebook and test the changes that you made.\n5. Once finished testing, kill the container using Ctrl-C\n\n\nNotice\n======\nThis 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.\nReference 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.\n\n\u003cdiv\u003e\n  \u003cpre style=\"text-align: center; font-size: 10pt;\"\u003e\n    PACIFIC NORTHWEST NATIONAL LABORATORY\n    operated by\n    BATTELLE\n    for the\n    UNITED STATES DEPARTMENT OF ENERGY\n    under Contract DE-AC05-76RL01830\n  \u003c/pre\u003e\n\u003c/div\u003e\n\n\n\nLicense\n=======\n\nReleased under the [3-Clause BSD license](LICENSE.rst)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnnl%2Fhypernetx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpnnl%2Fhypernetx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnnl%2Fhypernetx/lists"}