Skip to main content

NX-VIS Visualizer

uv pre-commit.ci CI & Deploy Netlify Status PyPI version License: MIT

NX-VIS Visualizer is a Python library designed to bridge the gap between NetworkX, a powerful graph manipulation library, and vis.js Network, a dynamic, browser-based visualization library. It allows you to easily render your NetworkX graphs as interactive HTML files or embed them directly into Jupyter Notebooks.

View the Documentation & Live Examples

Key Features

  • Seamless Conversion: Effortlessly convert NetworkX Graph and DiGraph objects into a format compatible with vis.js.
  • Rich Customization: Leverage the extensive vis.js Network options to tailor the appearance and behavior of your graphs (nodes, edges, layout, physics, interaction, etc.).
  • Node & Edge Styling: Apply vis.js styling attributes directly to your NetworkX nodes and edges.
  • Self-Contained HTML: Generate standalone HTML files that can be easily shared or embedded.
  • Jupyter Notebook Integration: Display interactive graphs directly within your Jupyter Notebooks or IPython environments.
  • Interactive Exploration: Enables panning, zooming, node dragging (if physics allows), and information display on hover/click.
  • Configurable UI: Optionally include a vis.js configuration panel within the generated HTML to tweak graph settings live in the browser.

Installation

You can install NX-VIS Visualizer using pip:

pip install nx-vis-visualizer

Alternatively, for development or to install from source:

git clone https://github.com/ParticularlyPythonicBS/nx-vis-visualizer.git
cd nx-vis-visualizer
uv pip install -e .

Quick Start

Here's a basic example of how to visualize a simple NetworkX graph:

import networkx as nx
from nx_vis_visualizer import nx_to_vis

# 1. Create a NetworkX graph
G = nx.cycle_graph(5)

# Add some basic attributes for visualization
for i, node_id in enumerate(G.nodes()):
    G.nodes[node_id]['label'] = f'Node {i+1}'
    G.nodes[node_id]['title'] = f'This is Node {i+1}' # Tooltip
    G.nodes[node_id]['group'] = i % 2

G.edges[0,1]['label'] = 'Link 0-1'
G.edges[0,1]['color'] = 'red'

# 2. Define (optional) vis.js options
custom_options = {
    "nodes": {"font": {"size": 16}},
    "edges": {"smooth": {"enabled": True}},
    "groups": {
        0: {"color": "skyblue", "shape": "dot"},
        1: {"color": "lightgreen", "shape": "square"}
    },
    "interaction": {"navigationButtons": True, "hover": True},
    "physics": {"enabled": True}
}

# 3. Generate and show the interactive HTML graph
# This will create 'cycle_graph.html' and open it in your browser.
nx_to_vis(
    G,
    output_filename="cycle_graph.html",
    html_title="My Interactive Cycle Graph",
    vis_options=custom_options,
    show_browser=True
)

# To get HTML for a Jupyter Notebook:
# html_output = nx_to_vis(G, vis_options=custom_options, notebook=True, show_browser=False)
# if html_output:
#     from IPython.display import HTML
#     display(HTML(html_output))

For more detailed examples, including directed graphs and advanced customizations, please see the Documentation.

Documentation

Full documentation, including API references and more examples, is available at: https://nx-vis-visualizer.netlify.app/

The documentation covers:

  • Installation
  • Basic Usage
  • Styling Nodes and Edges
  • Using vis.js Options
  • Directed Graphs
  • Advanced Customization
  • Jupyter Notebook Integration
  • API Reference

Contributing

Contributions are welcome! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please feel free to open an issue or submit a pull request.

To set up for development:

  1. Clone the repository:

    git clone https://github.com/ParticularlyPythonicBS/nx-vis-visualizer.git
    cd nx-vis-visualizer
    
  2. Install dependencies using uv:

    uv sync --all-extras --dev
    uv pip install -e . --no-deps
    
  3. Set up pre-commit hooks for code formatting and linting:

    uv run pre-commit install
    
  4. Run tests:

    uv run pytest tests
    

Please ensure your contributions pass all tests and adhere to the coding style (enforced by pre-commit hooks).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

Metadata

Release files for nx-vis-visualizer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nx-vis-visualizer 0.2.0
File Size Uploaded Provenance
nx_vis_visualizer-0.2.0.tar.gz 17.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nx-vis-visualizer 0.2.0
File Interpreter ABI Platform
nx_vis_visualizer-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / nx_vis_visualizer-0.2.0.tar.gz

Download URL nx_vis_visualizer-0.2.0.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
96b04a21473d1079c98eb49411d9557e76edf152a0565502d42718779ee6dfe7
BLAKE2b-256 checksum
How to use checksums
c3f59ed4f232274c23786a241db69d21dd5f17f55eb3cd7f024fe9b1289f34b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.12

Release files / nx_vis_visualizer-0.2.0-py3-none-any.whl

Download URL nx_vis_visualizer-0.2.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d334366863f0a5acd6fcce604e2ef16d555f7472e2b5ea7d889e1afa77362168
BLAKE2b-256 checksum
How to use checksums
9c5eef8786748d6b015d70941979adf611600df3e999667ec6955903338347f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.12

Security for nx-vis-visualizer 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page