Skip to main content

A simple graph visualization tool

Project description

Graph Visualization for Python by Neo4j

Latest version PyPI downloads month Python versions Documentation Discord Community forum License

neo4j-viz is a Python package for creating interactive graph visualizations based on data from Neo4j products.

The output is of type IPython.display.HTML and can be viewed directly in a Jupyter Notebook, Streamlit. Alternatively, you can export the output to a file and view it in a web browser.

The package wraps the Neo4j Visualization JavaScript library (NVL).

Proper documentation is forthcoming.

[!WARNING] This package is still in development and the API is subject to change.

Some notable features

  • Easy to import graphs represented as:
    • projections in the Neo4j Graph Data Science (GDS) library
    • pandas DataFrames
  • Node features:
    • Sizing
    • Colors
    • Captions
    • Pinning
  • Relationship features:
    • Colors
    • Captions
  • Graph features:
    • Zooming
    • Panning
    • Moving nodes
    • Using different layouts
  • Additional convenience functionality for:
    • Resizing nodes, optionally including scale normalization
    • Coloring nodes based on a property
    • Toggle whether nodes should be pinned or not

Please note that this list is by no means exhaustive.

Getting started

Installation

Simply install with pip:

pip install neo4j-viz

Basic usage

We will use a small toy graph representing the purchase history of a few people and products.

We start by instantiating the Nodes and Relationships we want in our graph. The only mandatory fields for a node are the "id", and "source" and "target" for a relationship. But the other fields can optionally be used to customize the appearance of the nodes and relationships in the visualization.

Lastly we create a VisualizationGraph object with the nodes and relationships we created, and call its render method to display the graph.

from neo4j_viz import Node, Relationship, VisualizationGraph

nodes = [
    Node(id=0, size=10, caption="Person"),
    Node(id=1, size=10, caption="Product"),
    Node(id=2, size=20, caption="Product"),
    Node(id=3, size=10, caption="Person"),
    Node(id=4, size=10, caption="Product"),
]
relationships = [
    Relationship(
        source=0,
        target=1,
        caption="BUYS",
    ),
    Relationship(
        source=0,
        target=2,
        caption="BUYS",
    ),
    Relationship(
        source=3,
        target=2,
        caption="BUYS",
    ),
]

VG = VisualizationGraph(nodes=nodes, relationships=relationships)

VG.render()

This will return a IPython.display.HTML object that can be rendered in a Jupyter Notebook or streamlit application.

Examples

For more extensive examples, including how to import graphs from Neo4j GDS projections and Pandas DataFrames, checkout the tutorials chapter in the documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neo4j_viz-0.2.1.tar.gz (489.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neo4j_viz-0.2.1-py3-none-any.whl (485.6 kB view details)

Uploaded Python 3

File details

Details for the file neo4j_viz-0.2.1.tar.gz.

File metadata

  • Download URL: neo4j_viz-0.2.1.tar.gz
  • Upload date:
  • Size: 489.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for neo4j_viz-0.2.1.tar.gz
Algorithm Hash digest
SHA256 86154be822c2cb902aa813028c28b420d80ea081441bd9248bb26a7aacf5c48d
MD5 669d390b5c6cf7d941cc124f4f3d76d4
BLAKE2b-256 97487957685879f6f179d0483c6affb4cb3ec274905a58d803488e3493513097

See more details on using hashes here.

File details

Details for the file neo4j_viz-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: neo4j_viz-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 485.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for neo4j_viz-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e69a0402273f7082203a4e48e2916b5b5b808361b5e04b20ee18d7466853095
MD5 cd907ff8652fa5d48cd239fc0d0c9975
BLAKE2b-256 ee2b15a0b82de518ebd75373c3ec65e7ddaeda216a2f7bf17ad2e50ab1b4d792

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page