Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cvamsikrishna11/952b89ab4335686c2296940a6e1a373b to your computer and use it in GitHub Desktop.
Save cvamsikrishna11/952b89ab4335686c2296940a6e1a373b to your computer and use it in GitHub Desktop.
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 2
// Create an empty graph database
graph = TinkerGraph.open()
// Create the TraversalSource
g = graph.traversal()
// Create the "person" vertex and assign it to "v1"
v1 = g.addV('person')\
.property(id, 1)\
.property('name', 'marko')\
.property('age', 29)\
.next()
// Create the "software" vertex and assign it to "v2"
v2 = g.addV('software')\
.property(id, 3)\
.property('name', 'lop')\
.property('lang', 'java')\
.next()
// Create the "created" edge from "v1" to "v2"
g.addE('created')\
.from(v1)\
.to(v2)\
.property(id, 9)\
.property('weight', 0.4)
// Get the name of the software created by "marko"
g.V()\
.has('person', 'name', 'marko')\
.out('created')\
.values('name')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment