Created
October 13, 2020 04:38
-
-
Save bassem-mf/bf072ea48748a2e26ca6adbb55000d1d to your computer and use it in GitHub Desktop.
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 2
This file contains 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