neo4j-viz0.2.6
Published
A simple graph visualization tool
pip install neo4j-viz
Package Downloads
Authors
Project URLs
Requires Python
>=3.9
Dependencies
- ipython
<10,>=7
- pydantic
<3,>=2
- pydantic-extra-types
<3,>=2
- enum-tools
==0.12.0
- ruff
==0.9.7; extra == "dev"
- mypy
==1.15.0; extra == "dev"
- pytest
==8.3.4; extra == "dev"
- selenium
==4.28.1; extra == "dev"
- ipykernel
==6.29.5; extra == "dev"
- palettable
==3.3.3; extra == "dev"
- pytest-mock
==3.14.0; extra == "dev"
- nbconvert
==7.16.6; extra == "dev"
- streamlit
==1.42.0; extra == "dev"
- sphinx
==8.1.3; extra == "docs"
- enum-tools
[sphinx]; extra == "docs"
- nbsphinx
==0.9.6; extra == "docs"
- nbsphinx-link
==1.3.1; extra == "docs"
- pandas
<3,>=2; extra == "pandas"
- pandas-stubs
<3,>=2; extra == "pandas"
- graphdatascience
<2,>=1; extra == "gds"
- neo4j
; extra == "neo4j"
- ipykernel
==6.29.5; extra == "notebook"
- pykernel
==0.1.6; extra == "notebook"
- neo4j
>=5.26.0; extra == "notebook"
- ipywidgets
>=8.0.0; extra == "notebook"
- palettable
==3.3.3; extra == "notebook"
- matplotlib
==3.10.0; extra == "notebook"
- snowflake-snowpark-python
==1.26.0; extra == "notebook"
Graph Visualization for Python by Neo4j
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).
[!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
- graphs from Neo4j query results
- 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.
Please refer to the documentation for more details on the API and usage.
Examples
For more extensive examples, including how to import graphs from Neo4j GDS projections and Pandas DataFrames, checkout the tutorials chapter in the documentation.