Forked from bassem-mf/GettingStartedTutorial3Commands.txt
Created
February 24, 2021 22:14
-
-
Save cvamsikrishna11/b027ddabd1bce3a0b891a70c2ccc6430 to your computer and use it in GitHub Desktop.
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 3
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 instance of the "Modern" toy graph and the traversal source in | |
// one command | |
g = TinkerFactory.createModern().traversal() | |
// Get the "age" values of the two "person"s named "vadas" and "marko" | |
g.V()\ | |
.has('person', 'name', within('vadas','marko'))\ | |
.values('age') | |
// Get the mean of the "age" values of the two "persons" named "vadas" and | |
// "marko" | |
g.V()\ | |
.has('person', 'name', within('vadas','marko'))\ | |
.values('age')\ | |
.mean() | |
// Get the "names" of the "persons" that "marko" "created" software with | |
// (flawed version) | |
g.V()\ | |
.has('person', 'name', 'marko')\ | |
.out('created')\ | |
.in('created')\ | |
.values('name') | |
// Get the "names" of the "persons" that "marko" "created" software with | |
// (good version) | |
g.V()\ | |
.has('person', 'name', 'marko')\ | |
.as('exclude')\ | |
.out('created')\ | |
.in('created')\ | |
.where(neq('exclude'))\ | |
.values('name') | |
// Place a Gremlin on every vertex in the graph then traverse out twice | |
g.V()\ | |
.out()\ | |
.out() | |
// Place a Gremlin on every vertex in the graph then traverse out twice then | |
// get the paths | |
g.V()\ | |
.as('a')\ | |
.out()\ | |
.as('b')\ | |
.out()\ | |
.as('c')\ | |
.select('a', 'b', 'c') | |
// Group all the vertices in the graph by their label | |
g.V()\ | |
.group()\ | |
.by(label) | |
// Group all the vertices in the graph by their label and use the "name" | |
// property as the item value | |
g.V()\ | |
.group()\ | |
.by(label)\ | |
.by('name') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment