aws/graph-notebook

Library extending Jupyter notebooks to integrate with Apache TinkerPop, openCypher, and RDF SPARQL.

What it is

Graph Notebook is an open-source Python package that brings graph databases into Jupyter notebooks — the popular interactive coding environment used by data scientists and developers. Instead of switching between a notebook and a separate database tool, you type query commands directly into notebook cells and see the results as formatted text or visual graph pictures.

What it does

It lets you connect to graph databases — databases that store data as nodes (things) and edges (relationships) — and run queries against them. Graph databases are used for things like knowledge graphs (connecting facts about entities) and identity graphs (mapping who is related to whom).

The package supports three major query languages:

  • Gremlin — from the Apache TinkerPop framework
  • openCypher / Cypher — the query language popularized by Neo4J
  • SPARQL — the standard language for RDF (semantic web) data

So whatever style of graph database you're using, there's likely a language here for it.

How it works — the 'magic' concept

In Jupyter, special commands that start with %% (for whole cells) or % (for single lines) are called "magics." Graph Notebook installs its own set of magics. For example:

  • %%gremlin — run a Gremlin query
  • %%sparql — run a SPARQL query
  • %%opencypher / %%oc — run an openCypher query
  • %status — check if your database is healthy
  • %seed — load sample data into the database
  • %stream_viewer — explore change streams (a Neptune feature)

You configure your database connection by running a magic command with a JSON payload specifying things like host, port, and authentication.

Supported databases

  • Gremlin Server — a local Apache TinkerPop server
  • Blazegraph — an RDF/SPARQL database
  • Amazon Neptune — AWS's managed graph database (supports all three languages)
  • Neo4J — the popular graph database using Cypher

The README even encourages the community to contribute configurations for other databases.

Visualization

A headline feature: when you run a query, the results can render as an actual graph picture — nodes and edges drawn out visually — not just raw text. The README shows screenshots of colorful graphs for each query language.

Installation

You install it via pip install graph-notebook, then run a few setup commands to enable the visualization widget and copy starter notebooks. There are separate instructions for Jupyter Classic Notebook and JupyterLab (with a newer 4.x version and an older 3.x legacy version). The README also includes a full build-from-source guide if you want the pre-release.

Getting started

The README strongly recommends exploring the bundled example notebooks, which document every feature with worked examples. For returning users, the Air-Routes notebooks in the 02-Visualization folder summarize new features.

Related

  • Project
  • Project
  • Project
  • Project