Skip to content
This repository

Many graph applications have to do with identifying patterns in the graph. That is, identifying sub-graphs that match a particular topology and/or feature set. In single-relational graphs, usually a topology is only considered. For graphs that are labeled and have key/value pairs on the elements (i.e. property graphs), then features on that topology must be considered as well to be generally useful.

The table pipe is useful for cataloging parts of the graph that match a particular pattern. The best way to explain its use is with respect to how the pattern match language SPARQL works. An example SPARQL query is provided below:

  marko knows ?x
  ?x created ?y

This query will return those vertices that Marko knows along with their respective creations. In Gremlin, this is accomplished as such.

g = TinkerGraphFactory.createTinkerGraph()
gremlin> t = new Table()                          
gremlin> g.v(1).out('knows').out('created').table(t,[1,2])
gremlin> t
==>[v[4], v[5]]
==>[v[4], v[3]]

Given the play graph diagrammed in Defining a Property Graph, a traversal is executed out from marko (vertex 1). The table step will select the 1st and 2nd part of the paths that reach it an insert them into the table. Moreover, its possible to evaluate closures over those path components.

gremlin> t = new Table()
gremlin> g.v(1).out('knows').out('created').table(t,[1,2]){}{}
gremlin> t
==>[josh, ripple]
==>[josh, lop]

As such, we found all the people that Marko knows who have created a product. Specifically, Marko knows Josh and Josh has created both Ripple and LoP.

Realize that table is side-effect step and thus, what enters the step, leaves unaltered on the other side.

Something went wrong with that request. Please try again.