Skip to content

Traversing With Gremlin

Jon Ivmark edited this page Nov 28, 2013 · 6 revisions

GraphIt implements the Blueprints interfaces via the wrapper class BlueprintsGraph, and you can therefor use Gremlin to traverse the graph.

Below is an example using this graph getting the name of all unique users that listened to the same tracks that John bought:

Graph graph = new BlueprintsGraph(musicStoreGraph);
GremlinPipeline<Vertex, Vertex> pipe =
    new GremlinPipeline<Vertex, Vertex>();
NodeId john = new NodeId(USER, "john.doe");
return pipe.start(graph.getVertex(john))
    .out(BOUGHT.name())
    .in(LISTENED_TO.name())
    .dedup()
    .property("Name")
    .toList();

A few more examples can be found here. For more information, please see the Gremlin wiki and javadoc.

Clone this wiki locally