Gremlin Query Results Visualisation using Neptune Workbench




Neptune Workbench with Jupyter Notebook can create visual diagrams for Gremlin or SPARQL query results. The visualisation of the query result is available in the Graph tab of the Jupyter Notebook. This article is about how to create Gremlin query result visuals using Workbench. I have taken a sample Twitter dataset for visualising the query results.

Creating and loading data into Neptune

For creating a Neptune cluster with Workbench and loading data from S3 into the Neptune database, refer to the following article.

Creating and loading data in to Neptune

After creating Neptune Cluster with Jupyter Notebook, check the version of the notebook to ensure that you have the latest version and check status to ensure if the Neptune server is healthy.


Visualising Gremlin query results

Neptune Workbench creates visual graph diagrams for Gremlin queries with a return "path". You can use --path-pattern (-p) with visualisation hints to control the visual diagram of the query result. The representation of path results can be modified by using the "by" modulator.

%%gremlin -p <comma-separated hints>
%%gremlin -p v,oute,inv


Visualisation Hints - The hints are Gremlin steps used for traversing between vertices. The hints can be of any combination from the below list. The hints are separated by commas without any spaces between them.

  • v
  • inv
  • outv
  • e
  • ine
  • oute


Visualisation of the Query with return path

The below query contains the return path(-p) but not edge information(outE) , so the edge directions are not determined automatically. Thus the visual diagram doesn’t show the direction of edges.

%%gremlin -p v


The following image shows the generated visual graph diagram for the above query in the Graph tab.


Visualisation of the Query with path and edge information

This query contains both the return path(-p) and the edge information(outE) , which determines the edge direction. The edge direction is determined by "outE".

%%gremlin -p v,oute,inv


The below image shows the query result visual with edge directions. Since "by" modulator is not specified in the query, the visualiser uses edge and vertex labels to annotate the graph.



Visualisation of the Query with path, edge information and by modulator

The query contains the path(-p), visualisation hint(outE) and "by" modulator, which makes it a complete query. The visual graph now contains edge directions with proper annotations.

%%gremlin -p v,oute,inv


The following image shows the graph visual of the above query with edge directions  and annotations.


Neptune Workbench also generates tabular form of the query result. The below image shows the Query result in tabular form in the Console tab.


Visualisation with details view

Use valueMap to get the result with a key-value map in the query. Click on the vertex and then choose the Details view icon to view the details in the scrollable list.

%%gremlin -p v,oute,inv


The below image shows the Details view of the query result.



We have seen the Visual graphs for various Gremlin query results. The Visualisation feature of Neptune Workbench allows you to get interactive graph diagrams of the query results. Visualisation of SPARQL query results can also be produced using Neptune workbench.