### Run Jupyter Notebooks (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/README.md After installing dependencies, this command starts the Jupyter Notebook server, opening the tutorial files in a web browser at the specified local URL. ```Shell make tutorials ``` -------------------------------- ### Installing Tutorial Dependencies and Running Tutorials (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the 'tutorials' dependency group using Poetry. It then shows commands to activate the environment and open Jupyter notebooks for tutorials using a `make tutorials` command. ```shell poetry install --with tutorials # activate your virtual environment created by poetry poetry shell # open Jupyter notebooks in a browser make tutorials ``` -------------------------------- ### Developer Setup using Make (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Sets up a development environment using 'make' targets. 'make venv' creates and activates the virtual environment, and 'make install' installs the necessary dependencies, assuming these targets are defined in a Makefile. ```Shell make venv source venv-hnx/bin/activate make install ``` -------------------------------- ### Start HyperNetX Container with Docker Compose (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Starts the HyperNetX service defined in the 'docker-compose.yml' file using the docker-compose command. ```Shell docker-compose up ``` -------------------------------- ### Developer Setup using Pip (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Sets up a development environment by creating and activating a virtual environment, then installing HyperNetX in editable mode ('-e .') and installing additional development dependencies from 'requirements.txt'. ```Shell python -m venv venv-hnx source venv-hnx/bin/activate pip install -e . pip install -r requirements.txt ``` -------------------------------- ### Install Tutorial Dependencies (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/README.md This command utilizes the Makefile to install all necessary Python packages required to run the HyperNetX tutorials within the activated virtual environment. ```Shell make tutorials-deps ``` -------------------------------- ### Installing Tutorial Dependencies with Make Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/README.md Install all required Python packages and dependencies necessary to run the Jupyter Notebook tutorials using a make command. ```Shell make tutorials-deps ``` -------------------------------- ### Install HyperNetX from Source (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Clones the HyperNetX GitHub repository, changes directory into it, creates and activates a virtual environment using 'make venv', and installs required dependencies using 'make install'. This method is used for installing from source. ```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 ``` -------------------------------- ### Installing Documentation Dependencies (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the 'docs' dependency group using Poetry, which includes tools required to build the project's documentation. ```shell poetry install --with docs ``` -------------------------------- ### Running Jupyter Notebooks with Make Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/README.md Start the Jupyter Notebook server to access and run the tutorial notebooks in your web browser. ```Shell make tutorials ``` -------------------------------- ### Build and Open HyperNetX Docs Locally (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Activates the poetry virtual environment, navigates to the docs directory, builds the HTML documentation using `make html`, and opens the generated index file in the browser. Requires poetry and Sphinx documentation setup. ```shell poetry shell cd docs make html open docs/build/html/index.html ``` -------------------------------- ### Install Tutorial Dependencies (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/README.md This command uses the project's Makefile to install all necessary Python packages required to run the hnxwidget Jupyter Notebook tutorials. ```Shell make tutorials-deps ``` -------------------------------- ### Install HyperNetX from PyPi (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the HyperNetX library into the currently active virtual environment using the pip package manager from the Python Package Index (PyPi). ```Shell pip install hypernetx ``` -------------------------------- ### Installing Lint Dependencies and Activating Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the 'lint' dependency group using Poetry, which includes tools like Pylint and Black. It then shows the command to activate the Poetry virtual environment. ```shell poetry install --with lint # activate your virtual environment created by poetry poetry shell ``` -------------------------------- ### Installing Pre-commit Hooks (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the pre-commit hooks into the Git repository. This command should be run once after cloning the repository to ensure hooks are triggered automatically on each commit. ```shell # Once installed, pre-commit will be triggered every time you make a commit in your environment pre-commit install ``` -------------------------------- ### Installing HyperNetX with Development Dependencies (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the HyperNetX library in editable mode along with specified optional dependency groups (test, lint, docs, release, tutorials) required for development. ```shell poetry install --with test,lint,docs,release,tutorials ``` -------------------------------- ### Installing Test Dependencies and Running Tests (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Installs the 'test' dependency group using Poetry. It then shows commands to activate the environment, run tests using pytest, run tests with coverage reporting, generate an HTML coverage report, and open it in a browser. ```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 ``` -------------------------------- ### Run Jupyter Notebooks (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/README.md This command starts the Jupyter notebook server, making the tutorial notebooks accessible via a web browser, typically at http://localhost:8888/tree. ```Shell make tutorials ``` -------------------------------- ### Build HyperNetX Docs with Live Reload (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Navigates to the docs directory and runs `make livehtml` to build the documentation with live reloading enabled. This allows for viewing changes in the browser automatically upon saving document files. Requires Sphinx documentation setup with livehtml capability. ```shell cd docs make livehtml ``` -------------------------------- ### Create Virtual Environment using venv (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Creates a virtual environment named 'venv-hnx' using Python's built-in 'venv' module and activates it. This isolates project dependencies from the system Python installation. ```Shell python -m venv venv-hnx source venv-hnx/bin/activate ``` -------------------------------- ### Activate Virtual Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/README.md This command activates the newly created virtual environment, ensuring subsequent commands use the isolated Python installation and packages. ```Shell source venv-hnx/bin/activate ``` -------------------------------- ### Running Pylint and Saving Report (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Executes the Pylint static code analyzer on the 'hypernetx' package and saves the analysis results to a file named "pylint-results.txt". ```shell pylint hypernetx --output=pylint-results.txt ``` -------------------------------- ### Run HyperNetX Tutorials from Source - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Executes the 'make tutorials' command from the HyperNetX source directory. This command typically launches a Jupyter Notebook server and opens the provided tutorial notebooks in a web browser. ```bash make tutorials ``` -------------------------------- ### Build HyperNetX Documentation from Source - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Navigates to the 'docs' directory within the HyperNetX source, builds the HTML documentation using 'make html', and then opens the generated index page in a web browser. ```bash cd docs make html open build/index.html ``` -------------------------------- ### Activating Poetry Virtual Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Activates the virtual environment managed by Poetry for the current project. This makes the project's dependencies available in the shell session. ```shell poetry shell ``` -------------------------------- ### Installing HyperNetX and hnxwidget (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Provides commands to install the `hypernetx` and `hnxwidget` libraries, typically used in environments like Google Colab. These are prerequisites for running the subsequent code. ```python # !pip install hypernetx ## uncomment to run in Colab # !pip install hnxwidget ``` -------------------------------- ### Build Multi-Platform HyperNetX Docker Image (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Builds a Docker image for HyperNetX supporting both linux/amd64 and linux/arm64 platforms. The `--rm` flag removes intermediate containers, and the `--tag` flag tags the image as `hypernetx/hypernetx:latest`. Requires Docker installed and configured for multi-platform builds. ```shell docker build --platform linux/amd64,linux/arm64 --rm --tag hypernetx/hypernetx:latest . ``` -------------------------------- ### Install HyperNetX from Source - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Clones the HyperNetX source code from GitHub, navigates into the directory, creates and activates a virtual environment using the Makefile, and then installs the library from the local source. ```bash git clone https://github.com/pnnl/HyperNetX.git cd HyperNetX make venv source venv-hnx/bin/activate make install ``` -------------------------------- ### Creating Virtual Environment with Make Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/README.md Use the make command to create a Python virtual environment for the project dependencies. ```Shell make venv ``` -------------------------------- ### Formatting Code with Black (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Runs the Black formatter on the 'hypernetx' package to automatically reformat the Python code according to PEP 8 standards. ```shell black hypernetx ``` -------------------------------- ### Configuring Poetry Virtual Environment Location (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Configures Poetry to create virtual environments within the project directory for convenience. The second command lists the current Poetry configuration settings to verify the change. ```shell poetry config virtualenvs.in-project true # check the poetry configuration poetry config --list ``` -------------------------------- ### Activate Virtual Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/README.md This command activates the 'venv-hnx' virtual environment, ensuring that subsequent Python commands use the packages installed within this environment. ```Shell source venv-hnx/bin/activate ``` -------------------------------- ### Running Pylint Static Analysis (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Executes the Pylint static code analyzer on the 'hypernetx' package to check for errors, enforce coding standards, and identify code smells. ```shell pylint hypernetx ``` -------------------------------- ### Run and Test HyperNetX Docker Image (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Runs the built HyperNetX Docker image interactively (`-it`), removes the container upon exit (`--rm`), maps port 8888 from the container to the host, and mounts the current working directory (`"${PWD}"`) to `/home/jovyan/work` inside the container. This is used for testing the image, typically by accessing a Jupyter environment via the mapped port. Requires Docker installed. ```shell docker run -it --rm -p 8888:8888 -v "${PWD}":/home/jovyan/work hypernetx/hypernetx:latest ``` -------------------------------- ### Activating Virtual Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/README.md Activate the newly created virtual environment using the source command to isolate project dependencies. ```Shell source venv-hnx/bin/activate ``` -------------------------------- ### Create Virtual Environment using virtualenv (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Creates a virtual environment named 'venv-hnx' using the 'virtualenv' tool and activates it. 'virtualenv' is a third-party alternative to Python's 'venv' module. ```Shell virtualenv venv-hnx source venv-hnx/bin/activate ``` -------------------------------- ### Run HyperNetX Docker Container (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Runs the latest HyperNetX Docker image in the foreground. It maps port 8888, removes the container on exit, and mounts the current working directory as a volume inside the container. ```Shell docker run -it --rm -p 8888:8888 -v "${PWD}":/home/jovyan/work hypernetx/hypernetx:latest ``` -------------------------------- ### Create Virtual Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/README.md This command uses the project's Makefile to create a Python virtual environment, isolating project dependencies. ```Shell make venv ``` -------------------------------- ### Install HyperNetX Dependency Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/Basic 2 - Visualization Methods.ipynb Installs the hypernetx library using pip. This line is commented out but can be uncommented for use in environments like Google Colab. ```python # !pip install hypernetx ## uncomment this to use Colab ``` -------------------------------- ### Install HyperNetX via Pip (Recommended) - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Installs the HyperNetX library from the Python Package Index (PyPi) using the pip package manager. This is the recommended method for most users. ```bash pip install hypernetx ``` -------------------------------- ### Create Virtual Environment (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/README.md This command uses the project's Makefile to create a Python virtual environment named 'venv-hnx' for isolating project dependencies. ```Shell make venv ``` -------------------------------- ### Run HyperNetX Docker Service with Docker Compose - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Starts the HyperNetX service defined in the docker-compose.yml file. This command builds or pulls the image if necessary and runs the container as configured in the file. ```bash docker-compose up ``` -------------------------------- ### Docker Compose Configuration for HyperNetX (YAML) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Defines a Docker Compose service for HyperNetX, specifying the image, port mapping, TTY allocation, standard input, and volume mapping for the work directory. This configuration can be saved as 'docker-compose.yml'. ```YAML version: '3' services: hypernetx: image: hypernetx/hypernetx:latest ports: - "8888:8888" tty: true stdin_open: true volumes: - "${PWD}:/home/jovyan/work" ``` -------------------------------- ### Activate Virtual Environment on Windows (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Activates a virtual environment named 'env-hnx' on Windows using the provided activation script. This command works in both Windows PowerShell and Command Prompt. ```Shell .\env-hnx\Scripts\activate ``` -------------------------------- ### Install HyperNetX via Pip (After Activation) - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Installs the HyperNetX library from PyPi using pip *after* a virtual environment has been activated. This ensures HyperNetX is installed into the isolated environment. ```bash pip install hypernetx ``` -------------------------------- ### Installing Hypernetx-Widget and Dependencies (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/widget.rst Provides the sequence of shell commands required to install Hypernetx-Widget, HyperNetX, Jupyter Notebook, and necessary extensions using Conda and Pip. It includes updating Conda, activating the base environment, installing packages, installing and enabling Jupyter extensions, and adding the base environment kernel to Jupyter. ```Shell # update conda conda update conda # activate the base environment conda activate # install hypernetx and hnxwidget pip install hypernetx hnxwidget # install jupyter notebook and extensions conda install -y -c anaconda notebook conda install -y -c conda-forge jupyter_contrib_nbextensions # install and enable the hnxwidget on jupyter jupyter nbextension install --py --symlink --sys-prefix hnxwidget jupyter nbextension enable --py --sys-prefix hnxwidget # install ipykernel and use it to add the base environment to jupyter notebook conda install -y -c anaconda ipykernel python -m ipykernel install --user --name=base # start the notebook jupyter-notebook ``` -------------------------------- ### Basic HyperNetX Usage in Python REPL - Python Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Demonstrates basic interaction with HyperNetX in a Python Read-Eval-Print Loop (REPL). It imports the library, creates a Hypergraph from data, and inspects its nodes, edges, and shape. ```python import hypernetx as hnx data = { 0: ('A', 'B'), 1: ('B', 'C'), 2: ('D', 'A', 'E'), 3: ('F', 'G', 'H', 'D') } H = hnx.Hypergraph(data) list(H.nodes) list(H.edges) H.shape ``` -------------------------------- ### Deactivate Virtual Environment on Windows (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Deactivates the currently active virtual environment on Windows using the provided deactivation script. ```Shell .\env-hnx\Scripts\deactivate ``` -------------------------------- ### Install HyperNetX in Development Mode Source: https://github.com/pnnl/hypernetx/blob/master/CONTRIBUTING.md This command installs the HyperNetX library from the current directory in editable mode. This allows changes to the source code to be reflected without needing to reinstall. ```Shell pip install -e . ``` -------------------------------- ### Install HypernetX (Colab) - Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/Basic 6 - Hypergraph Arithmetic.ipynb Provides a commented-out line to install the hypernetx library, useful for environments like Google Colab. ```python # !pip install hypernetx ## uncomment to run in Colab ``` -------------------------------- ### Create Virtual Environment using Anaconda (Shell) Source: https://github.com/pnnl/hypernetx/blob/master/README.md Creates a Conda environment named 'venv-hnx' with a specific Python version (3.11) and activates it. This is an alternative method for managing environments using the Anaconda distribution. ```Shell conda create -n venv-hnx python=3.11 -y conda activate venv-hnx ``` -------------------------------- ### Install HyperNetX with Testing Dependencies Source: https://github.com/pnnl/hypernetx/blob/master/CONTRIBUTING.md This command installs the HyperNetX library in editable mode along with the additional dependencies required for running tests and linting tools like `pytest` and `pre-commit`. ```Shell pip install -e .['testing'] ``` -------------------------------- ### Applying Greedy Matching Algorithm - HyperNetX Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 7 - Matching algorithms.ipynb Demonstrates how to call the greedy_matching function from hypernetx.algorithms.matching_algorithms with the example hypergraph and a specified number of partitions k. Prints the resulting matching. ```python k = 3 greedy_result = greedy_matching(hypergraph, k) print("Greedy Matching Result:", greedy_result) ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/pnnl/hypernetx/blob/master/CONTRIBUTING.md This command installs the Git pre-commit hooks configured in the project. These hooks automatically run linters and formatters on staged files before each commit, helping maintain code quality. Requires testing dependencies to be installed first. ```Shell pre-commit install ``` -------------------------------- ### Install HyperNetX Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/Basic 5 - HNX attributed hypergraph.ipynb This is a commented-out line suggesting how to install the hypernetx library using pip, typically used in environments like Google Colab. ```python # !pip install hypernetx ## uncomment if running in Colab ``` -------------------------------- ### Toy Example: Build Hypergraph and Display DataFrames Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Demonstrates building a simple hypergraph from a list of hyperedges. It initializes the hypergraph and displays the node and edge dataframes to show their default weights. ```python ## build a hypergraph from a list of sets (the hyperedges) E = [{'A','B'},{'A','C'},{'A','B','C'},{'A','D','E','F'},{'D','F'},{'E','F'},{'B'},{'G','B'}] kwargs = {'layout_kwargs': {'seed': 42}} Toy = hnx.Hypergraph(dict(enumerate(E))) ### Note that nodes and edges have weight = 1 by default pd.concat([Toy.nodes.to_dataframe,Toy.edges.to_dataframe]) ``` -------------------------------- ### UpSet Visualization with Sorted Edges Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Incidence Matrix.ipynb Demonstrates how to sort the edges in an UpSet plot by passing a sorted list of edges to the `edge_order` parameter. Includes setup for side-by-side comparison using Matplotlib subplots. ```python plt.figure(figsize=(20, 5)) plt.subplot(131) plt.title('Default') hnx.draw_incidence_upset(H) plt.subplot(132) plt.title('Sorted edge order') hnx.draw_incidence_upset( H, edge_order = sorted(H.edges) ) ``` -------------------------------- ### Create Virtual Environment with virtualenv - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Creates a new virtual environment named 'venv-hnx' using the virtualenv package and activates it. virtualenv is an alternative to venv. ```bash virtualenv venv-hnx source venv-hnx/bin/activate ``` -------------------------------- ### Import Libraries for Hypergraph Visualization Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Incidence Matrix.ipynb Imports necessary libraries: matplotlib for plotting, hypernetx for hypergraph operations, and the warnings module to ignore warnings. ```python import matplotlib.pyplot as plt import hypernetx as hnx import warnings warnings.simplefilter('ignore') ``` -------------------------------- ### Importing Libraries (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Two Column Bipartite.ipynb Imports the necessary libraries: matplotlib for plotting and hypernetx for hypergraph functionality. It also includes code to suppress warnings. ```python import matplotlib.pyplot as plt import hypernetx as hnx import warnings warnings.simplefilter('ignore') ``` -------------------------------- ### Creating Example Hypergraph - HyperNetX Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 7 - Matching algorithms.ipynb Defines a dictionary representing hyperedge data and uses it to instantiate a Hypergraph object from the hypernetx.classes.hypergraph module. This object serves as input for the matching algorithms. ```python # Example hypergraph data hypergraph_data = { 0: (1, 2, 3), 1: (4, 5, 6), 2: (7, 8, 9), 3: (1, 4, 7), 4: (2, 5, 8), 5: (3, 6, 9) } # Creating a Hypergraph hypergraph = Hypergraph(hypergraph_data) ``` -------------------------------- ### Loading Example Data for Chung-Lu Model Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 4 - Generative Models.ipynb Loads a preprocessed disease-gene dataset using hnx.utils.toys.GeneData to provide an example network for the Chung-Lu model, treating genes as vertices and diseases as hyperedges. It then prints the total number of vertices and hyperedges loaded. ```python gene_data = hnx.utils.toys.GeneData() genes = gene_data.genes diseases = gene_data.diseases disease_gene_network = gene_data.disease_gene_network print('Number of vertices: ', len(genes)) print('Number of hyperedges: ', len(diseases)) ``` -------------------------------- ### Define HyperNetX Docker Service (docker-compose.yml) - YAML Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Defines a Docker service for HyperNetX in a docker-compose.yml file. It specifies the image, port mapping, TTY/stdin settings for interactivity, and mounts the current directory as a volume. ```yaml version: '3' services: hypernetx: image: hypernetx/hypernetx:latest ports: - "8888:8888" tty: true stdin_open: true volumes: - "${PWD}:/home/jovyan/work" ``` -------------------------------- ### Starting Pandas DataFrame for Hypergraph Construction Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/hypconstructors.rst Begins the process of creating a pandas DataFrame intended for Hypergraph construction. The DataFrame structure is suitable for large datasets, with incidence pairs typically in the first two columns and cell properties in subsequent columns. This snippet shows the initial setup of the DataFrame. ```python import pandas as pd d = {'col1': ['e1', 'e1', 'e2'], 'col2': [1, 2, 1], ``` -------------------------------- ### Applying Iterated Sampling Algorithm - HyperNetX Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 7 - Matching algorithms.ipynb Shows how to use the iterated_sampling function from hypernetx.algorithms.matching_algorithms with the example hypergraph and a specified number of samples s. Prints the resulting matching. ```python s = 10 iterated_result = iterated_sampling(hypergraph, s) print("Iterated Sampling Result:", iterated_result) ``` -------------------------------- ### Toy Example: Draw Hypergraph Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Demonstrates drawing the previously created toy hypergraph using the `hnx.draw` function, setting a figure size and using layout keyword arguments. ```python plt.figure(figsize=(6,5)) hnx.draw(Toy, **kwargs) ``` -------------------------------- ### Applying HEDCS Matching Algorithm - HyperNetX Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 7 - Matching algorithms.ipynb Illustrates calling the HEDCS_matching function from hypernetx.algorithms.matching_algorithms with the example hypergraph and a specified number of samples s. Prints the resulting matching. ```python hedcs_result = HEDCS_matching(hypergraph, s) print("HEDCS Matching Result:", hedcs_result) ``` -------------------------------- ### Creating and Drawing Example Hypergraph Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 1 - s-Centrality.ipynb Defines a Python class SixByFive to construct a sample hypergraph from a numpy adjacency matrix. Instantiates the hypergraph and uses hnx.draw to visualize it. ```python class SixByFive(): """Example hypergraph with 6 nodes and 5 edges""" def __init__(self): mat = np.array([[1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0]]).transpose() self.hypergraph = hnx.Hypergraph.from_numpy_array(mat) H = SixByFive().hypergraph hnx.draw(H) ``` -------------------------------- ### Creating Hypergraph Data (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Two Column Bipartite.ipynb Defines a dictionary representing character occurrences in scenes from Les Miserables data. This dictionary is then used to initialize a HyperNetX Hypergraph object. ```python scenes = { 0: ('FN', 'TH'), 1: ('TH', 'JV'), 2: ('BM', 'FN', 'JA'), 3: ('JV', 'JU', 'CH', 'BM'), 4: ('JU', 'CH', 'BR', 'CN', 'CC', 'JV', 'BM'), 5: ('TH', 'GP'), 6: ('GP', 'MP'), 7: ('MA', 'GP') } H = hnx.Hypergraph(scenes) ``` -------------------------------- ### Define Data and Create Hypergraph Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Incidence Matrix.ipynb Defines a dictionary representing scene-character incidence data from Les Miserables and creates a Hypergraph object from this data using Hypernetx. ```python scenes = { 0: ('FN', 'TH'), 1: ('TH', 'JV'), 2: ('BM', 'FN', 'JA'), 3: ('JV', 'JU', 'CH', 'BM'), 4: ('JU', 'CH', 'BR', 'CN', 'CC', 'JV', 'BM'), 5: ('TH', 'GP'), 6: ('GP', 'MP'), 7: ('MA', 'GP') } H = hnx.Hypergraph(scenes) ``` -------------------------------- ### Drawing Bipartite Graph (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Two Column Bipartite.ipynb Draws a bipartite representation of the created hypergraph 'H' using the default Euler layout method provided by HyperNetX. ```python hnx.draw_bipartite_using_euler(H) ``` -------------------------------- ### Activate Virtual Environment (Windows) - Shell Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Activates a virtual environment named 'env-hnx' on Windows using its activation script. This command works in both PowerShell and Command Prompt. ```shell .\env-hnx\Scripts\activate ``` -------------------------------- ### Run HyperNetX Docker Container (Foreground) - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Runs the official HyperNetX Docker image in the foreground. It maps port 8888, removes the container upon exit, and mounts the current directory as a work volume inside the container. ```bash docker run -it --rm -p 8888:8888 -v "${PWD}":/home/jovyan/work hypernetx/hypernetx:latest ``` -------------------------------- ### Generate Basic UpSet Visualization Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Incidence Matrix.ipynb Generates a default UpSet plot for the created Hypergraph H using the hnx.draw_incidence_upset function. ```python hnx.draw_incidence_upset(H) ``` -------------------------------- ### Create Virtual Environment with Conda - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Creates a new virtual environment named 'venv-hnx' using Anaconda/Miniconda with Python 3.11 and activates it. The '-y' flag automatically confirms prompts. ```bash conda create -n venv-hnx python=3.11 -y conda activate venv-hnx ``` -------------------------------- ### Create Python Virtual Environment using Makefile Source: https://github.com/pnnl/hypernetx/blob/master/CONTRIBUTING.md This command uses the project's Makefile to create a Python virtual environment named 'venv-hnx'. This isolates project dependencies from the system Python installation. ```Shell make venv ``` -------------------------------- ### Create Virtual Environment with venv - Bash Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Creates a new virtual environment named 'venv-hnx' using Python's built-in venv module and activates it. This is a standard method for creating isolated Python environments. ```bash python -m venv venv-hnx source venv-hnx/bin/activate ``` -------------------------------- ### Applying Last-Step Hypergraph Clustering (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Demonstrates the 'last step' hypergraph clustering algorithm from `hmod`, starting with the predefined trivial partition `A4`. It refines the partition using `hmod.last_step` and then filters out any empty parts from the result. ```python ## hypergraph clustering -- start from trivial partition A4 defined above print('start from:', A4) A = hmod.last_step(Toy, A4) A = [s for s in A if len(s)>0] ## drop empty parts print('final partition:',A) ``` -------------------------------- ### Activate Python Virtual Environment (Linux/macOS) Source: https://github.com/pnnl/hypernetx/blob/master/CONTRIBUTING.md This command activates the previously created Python virtual environment named 'venv-hnx'. After activation, subsequent Python commands will use the environment's installed packages. ```Shell source venv-hnx/bin/activate ``` -------------------------------- ### Drawing Bipartite with Edge Order (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Two Column Bipartite.ipynb Creates a figure with two subplots to compare the default bipartite drawing with a drawing where the edges are explicitly sorted before rendering, demonstrating control over visualization layout. ```python plt.figure(figsize=(18, 6)) plt.subplot(131) plt.title('Default') hnx.draw_bipartite_using_euler(H) plt.subplot(132) plt.title('Sorted edge order') hnx.draw_bipartite_using_euler( H, edge_order=sorted(H.edges()) ) ``` -------------------------------- ### Collapsing Nodes and Getting Equivalence Classes (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Collapsed Hypergraphs.ipynb Calls `collapse_nodes` with `return_equivalence_classes=True` to collapse equivalent nodes and also return a dictionary `eq`. This dictionary maps the representative node in the collapsed hypergraph `Hc` to a list of all original nodes it represents. The dictionary `eq` is then displayed. ```python Hc, eq = H.collapse_nodes(return_equivalence_classes=True) eq ``` -------------------------------- ### UpSet Visualization with Custom Label Locations Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Incidence Matrix.ipynb Illustrates how to control the placement of node and edge labels in an UpSet plot using the `node_labels_on_axis` and `edge_labels_on_axis` parameters. Shows different combinations using Matplotlib subplots. ```python import matplotlib.pyplot as plt plt.figure(figsize=(10, 8)) plt.subplot(2, 2, 1) hnx.draw_incidence_upset(H) plt.title('Node label not on axis (default)') plt.ylabel("Edge label on axis (default)", rotation=90, fontsize=12, labelpad=20) # 90 degrees is vertical plt.subplot(2, 2, 2) hnx.draw_incidence_upset( H, node_labels_on_axis=True ) plt.title('Node label on axis') plt.subplot(2, 2, 3) hnx.draw_incidence_upset( H, edge_labels_on_axis=False ) plt.ylabel("Edge label not on axis", rotation=90, fontsize=12, labelpad=20) # 90 degrees is vertical plt.subplot(2, 2, 4) hnx.draw_incidence_upset( H, node_labels_on_axis=True, edge_labels_on_axis=False ) plt.tight_layout() plt.show() ``` -------------------------------- ### Define User-Supplied Quadratic and Cubic Weight Functions Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Defines two example user-supplied weight functions, `qH2` (quadratic) and `qH3` (cubic), for hypergraph modularity calculation. These functions return (c/d)**2 or (c/d)**3 respectively if the majority node count `c` exceeds half the edge size `d`, otherwise 0. ```python ## Examples of user-supplied weight functions ## square modularity def qH2(d,c): return (c/d)**2 if c > d/2 else 0 ## cubic modularity def qH3(d,c): return (c/d)**3 if c > d/2 else 0 ``` -------------------------------- ### Displaying Hypergraph with Default HypernetxWidget (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Instantiates the `HypernetxWidget` with the previously created hypergraph `H` using default visualization settings. Displaying the `example1` object renders the interactive widget. ```python ## Default behavior example1 = HypernetxWidget(H) example1 ``` -------------------------------- ### Importing Libraries for HyperNetX Widget Demo (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Imports the core `hypernetx` library, a specific dataset (`LesMis`) from its utilities, the `HypernetxWidget` for interactive visualization, and `matplotlib.pyplot` for potential plotting or color mapping. ```python import hypernetx as hnx from hypernetx.utils.toys.lesmis import LesMis from hnxwidget import HypernetxWidget import matplotlib.pyplot as plt ``` -------------------------------- ### Last-Step Clustering on Chung-Lu Hypergraph (Starting from Kumar) (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Applies the 'last step' hypergraph clustering algorithm to the Chung-Lu hypergraph (`CL`), using the partition (`KU`) obtained from Kumar's algorithm as the starting point. It uses the strict modularity function for the refinement process. ```python ## Last-step algorithm using previous result as initial partition random.seed(123) LS = hmod.last_step(CL, KU, hmod.strict) ``` -------------------------------- ### Deactivate Virtual Environment (Windows) - Shell Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/install.rst Deactivates the currently active virtual environment on Windows. This command works in both PowerShell and Command Prompt. ```shell .\env-hnx\Scripts\deactivate ``` -------------------------------- ### Importing Libraries for Hypergraph Matching - Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 7 - Matching algorithms.ipynb Imports necessary modules from standard libraries (numpy, random, logging, time, matplotlib) and the hypernetx library for hypergraph operations, matching algorithms, and performance plotting. ```python import numpy as np import hypernetx as hnx from hypernetx.classes.hypergraph import Hypergraph from hypernetx.algorithms.matching_algorithms import greedy_matching, iterated_sampling, HEDCS_matching import random import logging import time import matplotlib.pyplot as plt ``` -------------------------------- ### Importing Libraries for HypernetX and Plotting (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Collapsed Hypergraphs.ipynb Imports the `hypernetx` library for creating and manipulating hypergraphs, `matplotlib.pyplot` for plotting, and configures the `warnings` module to ignore simple warnings. ```python import hypernetx as hnx import matplotlib.pyplot as plt import warnings warnings.simplefilter('ignore') ``` -------------------------------- ### Retrieving HypernetxWidget State (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Calls the `get_state()` method on the `example2` widget instance. This method returns a dictionary containing the current visualization attributes and properties of the widget, which can be reused. ```python example2.get_state() ``` -------------------------------- ### Get All Incidence Properties in HyperNetX Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/Basic 5 - HNX attributed hypergraph.ipynb Uses the `get_properties` method to retrieve all attributes associated with a specific incidence. The `level=2` argument specifies that properties for incidences are requested. ```python H.get_properties(incidence, level = 2) #grab all properties for that incidence. Level = 2 is for incidences ``` -------------------------------- ### Visualizing Hypergraph with Calculated Properties (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Creates a `HypernetxWidget` instance `example5` using the hypergraph `H2` which contains calculated degree and size properties. It uses these properties to determine node and edge colors via a colormap. It also specifies which columns from the node and edge dataframes should be included as interactive data in the widget, allowing users to see these properties on hover. ```python ### All of the data in the property dataframes may be used in the widget except for the misc_properties ### Hover over nodes and edges to see the data associated with the object node_colors = {nd: plt.cm.Set1(H2.nodes[nd].degree) for nd in H2.nodes} edge_colors = {ed: plt.cm.Set1(H2.edges[ed].size) for ed in H2.edges} example5 = HypernetxWidget( H2, collapse_nodes=True, node_data=H2.nodes.dataframe[['weight', 'FullName', 'Description', 'degree']], edge_data=H2.edges.dataframe[['weight','size']], node_labels={'JV': 'Valjean'}, edge_labels={0: 'scene 0'}, nodes_kwargs={'color':node_colors}, edges_kwargs={'edgecolors':edge_colors} ) example5 ``` -------------------------------- ### Import HyperNetX and Matplotlib Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/Basic 2 - Visualization Methods.ipynb Imports the necessary libraries, hypernetx for hypergraph operations and matplotlib.pyplot for plotting and figure management. ```python import hypernetx as hnx import matplotlib.pyplot as plt # import warnings # warnings.simplefilter('ignore') ``` -------------------------------- ### Creating and Drawing a Hypergraph from Data (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Collapsed Hypergraphs.ipynb Defines a dictionary `scenes` where keys are scene numbers and values are tuples of characters present in the scene. It then creates a `hypernetx.Hypergraph` object `H` from this data and draws the initial hypergraph using `hnx.draw`. ```python scenes = { 0: ('FN', 'TH'), 1: ('TH', 'JV'), 2: ('BM', 'FN', 'JA'), 3: ('JV', 'JU', 'CH', 'BM'), 4: ('JU', 'CH', 'BR', 'CN', 'CC', 'JV', 'BM'), 5: ('TH', 'GP'), 6: ('GP', 'MP'), 7: ('MA', 'GP') } H = hnx.Hypergraph(scenes) hnx.draw(H) ``` -------------------------------- ### Comparing Hypergraph Matching Algorithm Performance - HyperNetX Python Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 7 - Matching algorithms.ipynb Defines a helper function to generate random d-uniform hypergraphs. It then iterates through different sizes, generates a hypergraph, runs each matching algorithm (greedy_matching, iterated_sampling, HEDCS_matching), measures execution time, and finally plots the results using matplotlib to visualize performance trends. ```python def generate_random_hypergraph(n, d, m): edges = {f'e{i}': random.sample(range(1, n+1), d) for i in range(m)} return Hypergraph(edges) # Generate random hypergraphs of increasing size sizes = [100, 200, 300, 400, 500] greedy_times = [] iterated_times = [] hedcs_times = [] for size in sizes: hypergraph = generate_random_hypergraph(size, 3, size) start_time = time.time() greedy_matching(hypergraph, k) greedy_times.append(time.time() - start_time) start_time = time.time() iterated_sampling(hypergraph, s, max_iterations = 500) iterated_times.append(time.time() - start_time) start_time = time.time() HEDCS_matching(hypergraph, s) hedcs_times.append(time.time() - start_time) # Plot the results plt.figure(figsize=(10, 6)) plt.plot(sizes, greedy_times, label='Greedy Matching') plt.plot(sizes, iterated_times, label='Iterated Sampling') plt.plot(sizes, hedcs_times, label='HEDCS Matching') plt.xlabel('Hypergraph Size') plt.ylabel('Time (seconds)') plt.title('Performance Comparison of Hypergraph Matching Algorithms') plt.legend() plt.show() ``` -------------------------------- ### Using Hypernetx Matching Algorithms in Python Source: https://github.com/pnnl/hypernetx/blob/master/docs/source/algorithms/matching_algorithms.rst This snippet demonstrates how to import and use the different hypergraph matching approximation algorithms provided by the `hypernetx.algorithms.matching_algorithms` module. It shows calls to the O(d²), d, and d(d−1 + 1/d)² approximation functions. ```python from hypernetx.algorithms import matching_algorithms as ma # Example hypergraph data hypergraph = ... # Assume this is a d-uniform hypergraph # Compute a matching using the O(d²)-approximation algorithm matching = ma.matching_approximation_d_squared(hypergraph) # Compute a matching using the d-approximation algorithm matching_d = ma.matching_approximation_d(hypergraph) # Compute a matching using the d(d−1 + 1/d)²-approximation algorithm matching_d_squared = ma.matching_approximation_dd(hypergraph) print(matching, matching_d, matching_d_squared) ``` -------------------------------- ### Import Libraries and Setup Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/basic/Basic 5 - HNX attributed hypergraph.ipynb Imports necessary libraries including matplotlib for plotting and hypernetx. It also includes settings to ignore specific warnings and sets a parameter for text size in plots. ```python import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import hypernetx as hnx import warnings warnings.simplefilter('ignore') warnings.filterwarnings("ignore", category=DeprecationWarning) #set plotting parameters TextSize = 15 ``` -------------------------------- ### Importing Libraries for Hypergraph Generation Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 4 - Generative Models.ipynb Imports necessary Python libraries for hypergraph generation and analysis, including hypernetx, its generative models module, random, matplotlib, time, warnings, and collections.Counter. ```python import hypernetx as hnx import hypernetx.algorithms.generative_models as gm import random import matplotlib.pyplot as plt import time import warnings warnings.simplefilter('ignore') from collections import Counter ``` -------------------------------- ### Perform Clustering using Simple qH-based Algorithm (Last-Step) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Computes a partition of the hypergraph vertices using the Last-Step algorithm, given an initial partition A. The `wcd` parameter sets the weight function (default linear), and `delta` is the convergence criterion. The partition is returned as a list of sets. ```python LS = hmod.last_step(H, A, wdc=hmod.linear, delta = .01) ``` -------------------------------- ### Creating HyperNetX Hypergraph from Les Misérables Data (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Defines a dictionary representing scenes and the characters present in each, then uses it to construct a `Hypergraph` object `H` using the `hypernetx` library. It also loads character names (`dnames`) from the Les Misérables toy dataset. ```python scenes = { 0: ('FN', 'TH'), 1: ('TH', 'JV'), 2: ('BM', 'FN', 'JA'), 3: ('JV', 'JU', 'CH', 'BM'), 4: ('JU', 'CH', 'BR', 'CN', 'CC', 'JV', 'BM'), 5: ('TH', 'GP'), 6: ('GP', 'MP'), 7: ('MA', 'GP'), } H = hnx.Hypergraph(scenes) dnames = LesMis().dnames dnames ``` -------------------------------- ### Demonstrating HyperNetX Node Labeling Options (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/visualization/Advanced Visualization for Collapsed Hypergraphs.ipynb This Python snippet demonstrates how to apply different labeling options using the `create_labels` function and visualize the results. It iterates through predefined keyword argument sets, generates customized labels for a hypergraph `Hc` (assuming `eq` is the equivalence class), and draws the hypergraph using `hnx.draw`. The code also shows how to use the `pos` and `return_pos` arguments to ensure a consistent layout across multiple plots. Requires `hypernetx` (imported as `hnx`) and `matplotlib.pyplot` (imported as `plt`). `Hc`, `eq`, and `get_node_radius` are assumed to be defined elsewhere. ```python # all labeling options kwargs_options = [ ('Default', dict()), ('As Sets', dict(as_set=True)), ('Without Counts', dict(with_counts=False)), ('Without Labels', dict(with_labels=False)), ('With Singletons', dict(include_singletons=True)), ('Only Counts', dict(with_labels=False, include_singletons=True)) ] pos = None # initial position is unset (will be calculated by layout algorithm) plt.figure(figsize=(15, 10)) for i, (t, kwargs) in enumerate(kwargs_options): # customize the node labels based on the kwargs option labels = node_labels=create_labels(eq, **kwargs) plt.subplot(2, 3, i + 1) plt.title(f'Option {i + 1}: {t}') pos = hnx.draw( Hc, pos=pos, # set the node positions to the position of the previous drawing return_pos=True, # return the node positions so it can be used by subsequent drawings node_radius=get_node_radius, # reuse this function from a previous examples node_labels=labels # pass in the custoimzed labels ) ``` -------------------------------- ### Displaying Hypergraph with Preset Node and Edge Attributes (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Creates a dictionary `node_colors` to color specific nodes red and others blue. It then instantiates the `HypernetxWidget` with `H`, applying these custom node colors and setting edge colors to green using `nodes_kwargs` and `edges_kwargs`. ```python node_colors = {k:'r' if k in ['JV','TH','FN'] else 'b' for k in H.nodes} example2 = HypernetxWidget( H, nodes_kwargs={'color':node_colors}, edges_kwargs={'edgecolors':'g'} ) example2 ``` -------------------------------- ### Count Edges within Same Partition - Hypernetx Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/advanced/Advanced 6 - Hypergraph Modularity and Clustering.ipynb Counts the number of hyperedges in the hypergraph CL where all incident vertices belong to the same community or partition as defined by the LS Partition object. It uses hmod.part2dict to get the partition mapping. ```python print('edges with all vertices in same part:', sum([len(set([hmod.part2dict(LS)[v] for v in CL.edges[e]]))==1 for e in CL.edges()])) ``` -------------------------------- ### Reusing Node Color Attributes in HypernetxWidget (Python) Source: https://github.com/pnnl/hypernetx/blob/master/tutorials/widget/Demo 1 - HNXWidget.ipynb Creates a new `HypernetxWidget` instance `example3` using the hypergraph `H`. It reuses the `nodeFill` property (which corresponds to node color) from the `props` attribute of the `example2` widget instance, demonstrating how to apply attributes from one visualization to another. ```python ## example3 = HypernetxWidget( H, nodes_kwargs={'color': example2.props["nodeFill"]} ) example3 ```