Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cvamsikrishna11/55da4c6ffd9ae806e79465b7f5f60223 to your computer and use it in GitHub Desktop.
Save cvamsikrishna11/55da4c6ffd9ae806e79465b7f5f60223 to your computer and use it in GitHub Desktop.
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 1
// Create an instance of the "Modern" toy graph
graph = TinkerFactory.createModern()
// Create the traversal source
g = graph.traversal()
// Get all vertices
g.V()
// Get the vertex with the ID "1"
g.V(1)
// Get the value of the "name" property on the vertex with the ID "1"
g.V(1).values('name')
// Start from the vertex with ID "1" and get the outgoing edges labeled "knows"
g.V(1).outE('knows')
// Get the names of the people vertex "1" knows (long version)
g.V(1).outE('knows').inV().values('name')
// Get the names of the people vertex "1" knows (concise version)
g.V(1).out('knows').values('name')
// Get the names of the people vertex "1" knows who are over the age of 30
g.V(1).out('knows').has('age', gt(30)).values('name')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment