Last active
May 28, 2024 16:09
-
-
Save bassem-mf/ff9d607dc08d5aad51761f70603eb103 to your computer and use it in GitHub Desktop.
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 1
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 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