Skip to main content

GQVis

A simple package for visualising the results of a graph query (to Neo4j) in an interactive Python environment (such as Jupyter notebook).

Screenshot of an example graph

Installation

Simply run:

pip install gqvis

Usage

First, import the package via

import gqvis

There are two ways to use this package, detailed below.

Visualising the result of a Neo4j Cypher query

The first way to use the class is to visualise the result of a Neo4j Cypher query. This requires you to have a Neo4j database running.

You must first create an environment variable called NEO4J_PASSWORD and set the value of this variable to the password of your Neo4j graph. In Jupyter, you can simply do:

%env NEO4J_PASSWORD=password

The default password is 'password', so if your Neo4j graph already has this password there is no need to set this variable.

Then, you can run the following:

gqvis.visualise_cypher('MATCH (n1:Entity)-[r]->(n2:Entity) RETURN n1, r, n2 LIMIT 500')

Note that unlike Neo4j, which has the 'connect result nodes' option to automatically connect nodes that have relationships, you will need to return the relationships explicitly in your query. Only relationships in the RETURN statement will be visualised.

You can also visualise a given list of nodes and edges - No Neo4j required. For example:

nodes = [
    {
      "id": 1,
      "category": "Person",
      "name": "Bob",
    },
    {
      "id": 2,
      "category": "Food",
      "name": "Jelly",
    },
    {
      "id": 3,
      "category": "Person",
      "name": "Alice",
    }
]
links = [
    {
      "source": 1,
      "target": 2,
      "type": "EATS",
    },
    {
      "source": 3,
      "target": 1,
      "type": "LIKES",
    },
]
gqvis.visualise_list(nodes, links)

This will create a graph visualisation with three nodes ("Bob", "Jelly", "Alice"), and two links (Bob eats Jelly, Alice likes Bob). You can have other properties (such as "age": 45 on Bob) - they'll be shown in the tooltip when hovering over a node.

The "id", "category" and "name" properties are required on each node. The "name" property is what will be written on the nodes in the visualisation, while the "category" will determine their colour (more on this below).

For the links, "source" is the id of the source node, "target" is the id of the target node, and "type" is the type of relationship. These are all required.

About the visualisation

Nodes are coloured based on the category property.

For the Cypher visualisation, the way the graph decides on the colour of each node is based on the last label of that node, i.e. if a node had the following labels:

Entity, Item

... it would be coloured based on the Item label. The colours are determined automatically, i.e. each category receives its own unique colour.

Notes

We use the dependency neo4j (the Neo4j driver for Python) rather than py2neo because it turns out py2neo does not output the exact same results as Neo4j. The way this whole thing works is by creating a list of nodes from all node objects returned by the cypher query, then creating links (by linking nodes via their ids). It didn't seem possible in py2neo, but was pretty straightforward with the neo4j package.

You can run src/template/template.html by itself (i.e. open it directly in Firefox/Chrome) for development purposes. When running it this way, it will be populated by some dummy data specified in src/template/dummyData.js.

Note that you must have an internet connection to use this package at the moment as it pulls D3.js from an online CDN.

Metadata

Release files for gqvis 0.1.15

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

Source distribution (sdist)

Source distribution for gqvis 0.1.15
File Size Uploaded Provenance Actions
gqvis-0.1.15.tar.gz 16.1 kB Without provenance Details for gqvis-0.1.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gqvis 0.1.15
File Interpreter ABI Platform Actions
gqvis-0.1.15-py3-none-any.whl Python 3 none any Details for gqvis-0.1.15-py3-none-any.whl

Total release size: 35.8 kB

Release files / gqvis-0.1.15.tar.gz

Download URL gqvis-0.1.15.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7ec79aad4edf4dfd690d4f21f71f575d1510ba163ec797bcd9bba0254055eead
BLAKE2b-256 checksum
How to use checksums
bc0ace5e6b0a4d4b0135a5230c4c2deb56ac35daf263664b700f98c3dcbbde92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.7.4 Windows/10

Release files / gqvis-0.1.15-py3-none-any.whl

Download URL gqvis-0.1.15-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77011a6c3a3b8fb2e77df7350ef246016a451ca8db95a5520510816a7ca09f91
BLAKE2b-256 checksum
How to use checksums
308a9d41b0508e6f6eba16a1e4534de47cf40beeb44325664950de9fcceeb2c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.7.4 Windows/10

Security for gqvis 0.1.15

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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