Forked from bassem-mf/GettingStartedTutorial2Commands.txt
Created
February 24, 2021 22:14
-
-
Save cvamsikrishna11/952b89ab4335686c2296940a6e1a373b to your computer and use it in GitHub Desktop.
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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