SlideShare a Scribd company logo
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
// An Exapmle of TinkerGraph
Graph graph = new TinkerGraph();
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
a.setProperty("name", "marko");
b.setProperty("name", "peter");
Edge e = graph.addEdge(null, a, b, "knows");
// marko--knows-->peter
public void testIteratingGraph() {
  Graph graph = TinkerGraphFactory.createTinkerGraph();
  System.out.println("Vertices of " + graph);
  for (Vertex vertex : graph.getVertices()) {
       System.out.println(vertex);
  }
  System.out.println("Edges of " + graph);
  for (Edge edge : graph.getEdges()) {
       System.out.println(edge);
   }
Vertices of tinkergraph[vertices:6 edges:6]
}
v[3]
v[2]
...
Edges of tinkergraph[vertices:6 edges:6]
e[10][4-created->5]
e[7][1-knows->2]
...
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
{
                                                 "a" : 1,
http://localhost:8182/graphs/toygraph/toy-
                                                 "b" : {
traversal?
                                                     "a" : "marko",
a=1&b.a=marko&b.b=true&b.c.a=peter&c=[mark           "b" : true,
o,povel]                                             "c" : {
                                                         "a" : "peter"
                                                     }
                                                 }
                                                 "c" : ["marko","povel"]
                                             }
curl -sX GET "http://aHost:8182/graphs/neo4jsample/indices/vertices?key=ID&value=52"
{
    "version": "0.4-SNAPSHOT",
    "results": [
         {
             "_id": 149,
             "_type": "vertex",
             "Name": "King",
             "Type": "Card",
             "ID": "52"
         }
    ],
    "totalSize": 1,
    "queryTime": 3.876749
}
An Introduction to Tinkerpop
~$ gremlin


           ,,,/
           (o o)
-----oOOo-(_)-oOOo-----
gremlin>
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> v = g.v(1)
==>v[1]
gremlin> v.outE
==>e[7][1-knows->2]
==>e[9][1-created->3]
==>e[8][1-knows->4]
gremlin> v.outE.inV
==>v[2]
==>v[3]
==>v[4]
# vertex jump
gremlin> v.outE.inV.outE.inV
==>v[5]
==>v[3]
# shortcut
gremlin> v.out.out
==>v[5]
==>v[3]

# using filter
gremlin> v.outE.filter{it.label=='knows'}.inV.filter{it.age >
30}.name
==>josh
#   backtracking and an in-line regular expression
gremlin> v.out('knows').filter{it.age >
21}.name.filter{it.matches('jo.{2}|JO.{2}')}.back(3).age
==>32
# return path
gremlin> g.v(1).outE.inV.name.paths
==>[v[1], e[7][1-knows->2], v[2], vadas]
==>[v[1], e[9][1-created->3], v[3], lop]
==>[v[1], e[8][1-knows->4], v[4], josh]


gremlin> g.v(1).outE.inV.paths{it.name}{it.weight}{it.name}
==>[marko, 0.5, vadas]
==>[marko, 0.4, lop]
==>[marko, 1.0, josh]
# loop
gremlin> g.v(89).outE.inV.paths
==>[v[89], e[7021][89-followed_by->83], v[83]]
==>[v[89], e[7022][89-followed_by->21], v[21]]
==>[v[89], e[7006][89-followed_by->127], v[127]]
...
gremlin> g.v(89).outE.inV.loop(2){it.loops < 3}.paths
==>[v[89], e[7021][89-followed_by->83], v[83], e[1411][83-followed_by->13],
v[13]]
==>[v[89], e[7021][89-followed_by->83], v[83], e[1410][83-followed_by->12],
v[12]]
==>[v[89], e[7021][89-followed_by->83], v[83], e[1415][83-followed_by->114],
v[114]]
==>[v[89], e[7021][89-followed_by->83], v[83], e[1414][83-followed_by->15],
v[15]]
...
gremlin> g.v(89).outE.inV.loop(2){it.loops < 3} == g.v(89).outE.inV.outE.inV
==>true
An Introduction to Tinkerpop
An Introduction to Tinkerpop
An Introduction to Tinkerpop
gremlin> g.v(1).out.name   gremlin>
==>vadas                   g.v(1).out.name.paths
==>lop                     ==>[v[1], v[2], vadas]
==>josh                    ==>[v[1], v[3], lop]
                           ==>[v[1], v[4], josh]
gremlin> g.v(1).out('knows')
==>v[2]
==>v[4]
gremlin> g.v(1).out('knows').filter{it.age < 30}
==>v[2]
gremlin> g.v(1).out('knows').filter{it.age < 30}.name
==>vadas
gremlin> g.v(1).out('knows').filter{it.age <
30}.name.transform{it.length()}
==>5
gremlin> g.v(1).out('knows')
==>v[2]
==>v[4]
gremlin> g.v(1).out('knows').filter{it.age < 30}
==>v[2]
gremlin> g.v(1).out('knows').filter{it.age < 30}.name
==>vadas
gremlin> g.v(1).out('knows').filter{it.age <
30}.name.transform{it.length()}
==>5
gremlin> g.v(1).out('knows').ifThenElse{it.age < 30}
{it.name}{it.out('created').name}
==>vadas
==>ripple
==>lop
gremlin> g.v(1).out('knows').name
==>vadas
==>josh
gremlin> g.v(1).out('knows').name.filter{it[0]=='v'}
==>vadas
gremlin>
g.v(1).out('knows').name.filter{it[0]=='v'}.back(2)
==>v[2]
gremlin>
g.v(1).out('knows').name.filter{it[0]=='v'}.back(2)
==
g.v(1).out('knows').as('here').name.filter{it[0]=='v'}.back('here')
gremlin> g.v(1).out.loop(1){it.loops < 3}
==>v[5]
==>v[3]
An Introduction to Tinkerpop

More Related Content

PDF
Drawing on canvas
PDF
Myraytracer
PPTX
PPT
C questions
DOCX
A simple snake game project
DOCX
Hangman Game Programming in C (coding)
PDF
FalcorJS
Drawing on canvas
Myraytracer
C questions
A simple snake game project
Hangman Game Programming in C (coding)
FalcorJS

What's hot (19)

PPTX
Introduzione a C#
DOCX
Ping pong game
PDF
[SI] Ada Lovelace Day 2014 - Tampon Run
PPTX
MongoDB
DOCX
Travel management
PDF
C++ Programming - 14th Study
PPTX
Paperjs presentation
PPT
Cquestions
DOCX
Ejercicios de programacion
PDF
Implementing string
DOCX
DOCX
C program to implement linked list using array abstract data type
PDF
Pointer level 2
PDF
2. Базовый синтаксис Java
DOCX
Circular queue
PDF
2² C# 4.0 and .NET 4 Selected Features
PDF
ECMAScript 6 major changes
Introduzione a C#
Ping pong game
[SI] Ada Lovelace Day 2014 - Tampon Run
MongoDB
Travel management
C++ Programming - 14th Study
Paperjs presentation
Cquestions
Ejercicios de programacion
Implementing string
C program to implement linked list using array abstract data type
Pointer level 2
2. Базовый синтаксис Java
Circular queue
2² C# 4.0 and .NET 4 Selected Features
ECMAScript 6 major changes
Ad

Similar to An Introduction to Tinkerpop (20)

PPTX
Groovy
PDF
Malli: inside data-driven schemas
PDF
SWP - A Generic Language Parser
PDF
MongoDB Analytics
PDF
All I know about rsc.io/c2go
PDF
Useful javascript
PDF
Tips and Tricks for Avoiding Common Query Pitfalls
TXT
Fcontratos
PDF
JavaOne2010 Groovy/Spring Roo
ODP
ELK Stack - Turn boring logfiles into sexy dashboard
PDF
A Few of My Favorite (Python) Things
TXT
Agile Testing Days 2018 - API Fundamentals - postman collection
PDF
Is Haskell an acceptable Perl?
PDF
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
PDF
Ten modules I haven't yet talked about
PDF
The Ring programming language version 1.5 book - Part 8 of 31
PDF
jq: JSON - Like a Boss
PDF
The Web map stack on Django
PDF
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Groovy
Malli: inside data-driven schemas
SWP - A Generic Language Parser
MongoDB Analytics
All I know about rsc.io/c2go
Useful javascript
Tips and Tricks for Avoiding Common Query Pitfalls
Fcontratos
JavaOne2010 Groovy/Spring Roo
ELK Stack - Turn boring logfiles into sexy dashboard
A Few of My Favorite (Python) Things
Agile Testing Days 2018 - API Fundamentals - postman collection
Is Haskell an acceptable Perl?
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Ten modules I haven't yet talked about
The Ring programming language version 1.5 book - Part 8 of 31
jq: JSON - Like a Boss
The Web map stack on Django
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Ad

More from Takahiro Inoue (20)

PDF
Treasure Data × Wave Analytics EC Demo
PDF
トレジャーデータとtableau実現する自動レポーティング
PDF
Tableauが魅せる Data Visualization の世界
PDF
トレジャーデータのバッチクエリとアドホッククエリを理解する
PDF
20140708 オンラインゲームソリューション
PDF
トレジャーデータ流,データ分析の始め方
PDF
オンラインゲームソリューション@トレジャーデータ
PDF
事例で学ぶトレジャーデータ 20140612
PDF
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
PDF
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
PDF
Treasure Data Intro for Data Enthusiast!!
PDF
Hadoop and the Data Scientist
PDF
MongoDB: Intro & Application for Big Data
PDF
An Introduction to Fluent & MongoDB Plugins
PDF
An Introduction to Neo4j
PDF
The Definition of GraphDB
PDF
Large-Scale Graph Processing〜Introduction〜(完全版)
PDF
Large-Scale Graph Processing〜Introduction〜(LT版)
PDF
Advanced MongoDB #1
PDF
はじめてのGlusterFS
Treasure Data × Wave Analytics EC Demo
トレジャーデータとtableau実現する自動レポーティング
Tableauが魅せる Data Visualization の世界
トレジャーデータのバッチクエリとアドホッククエリを理解する
20140708 オンラインゲームソリューション
トレジャーデータ流,データ分析の始め方
オンラインゲームソリューション@トレジャーデータ
事例で学ぶトレジャーデータ 20140612
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
Treasure Data Intro for Data Enthusiast!!
Hadoop and the Data Scientist
MongoDB: Intro & Application for Big Data
An Introduction to Fluent & MongoDB Plugins
An Introduction to Neo4j
The Definition of GraphDB
Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(LT版)
Advanced MongoDB #1
はじめてのGlusterFS

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
cuic standard and advanced reporting.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced IT Governance
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Spectroscopy.pptx food analysis technology
KodekX | Application Modernization Development
Chapter 3 Spatial Domain Image Processing.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
cuic standard and advanced reporting.pdf
Understanding_Digital_Forensics_Presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
Advanced IT Governance
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Spectroscopy.pptx food analysis technology

An Introduction to Tinkerpop

  • 10. // An Exapmle of TinkerGraph Graph graph = new TinkerGraph(); Vertex a = graph.addVertex(null); Vertex b = graph.addVertex(null); a.setProperty("name", "marko"); b.setProperty("name", "peter"); Edge e = graph.addEdge(null, a, b, "knows"); // marko--knows-->peter
  • 11. public void testIteratingGraph() { Graph graph = TinkerGraphFactory.createTinkerGraph(); System.out.println("Vertices of " + graph); for (Vertex vertex : graph.getVertices()) { System.out.println(vertex); } System.out.println("Edges of " + graph); for (Edge edge : graph.getEdges()) { System.out.println(edge); } Vertices of tinkergraph[vertices:6 edges:6] } v[3] v[2] ... Edges of tinkergraph[vertices:6 edges:6] e[10][4-created->5] e[7][1-knows->2] ...
  • 15. { "a" : 1, http://localhost:8182/graphs/toygraph/toy- "b" : { traversal? "a" : "marko", a=1&b.a=marko&b.b=true&b.c.a=peter&c=[mark "b" : true, o,povel] "c" : { "a" : "peter" } } "c" : ["marko","povel"] }
  • 16. curl -sX GET "http://aHost:8182/graphs/neo4jsample/indices/vertices?key=ID&value=52" { "version": "0.4-SNAPSHOT", "results": [ { "_id": 149, "_type": "vertex", "Name": "King", "Type": "Card", "ID": "52" } ], "totalSize": 1, "queryTime": 3.876749 }
  • 18. ~$ gremlin ,,,/ (o o) -----oOOo-(_)-oOOo----- gremlin>
  • 22. gremlin> g = TinkerGraphFactory.createTinkerGraph() ==>tinkergraph[vertices:6 edges:6] gremlin> v = g.v(1) ==>v[1] gremlin> v.outE ==>e[7][1-knows->2] ==>e[9][1-created->3] ==>e[8][1-knows->4] gremlin> v.outE.inV ==>v[2] ==>v[3] ==>v[4]
  • 23. # vertex jump gremlin> v.outE.inV.outE.inV ==>v[5] ==>v[3] # shortcut gremlin> v.out.out ==>v[5] ==>v[3] # using filter gremlin> v.outE.filter{it.label=='knows'}.inV.filter{it.age > 30}.name ==>josh # backtracking and an in-line regular expression gremlin> v.out('knows').filter{it.age > 21}.name.filter{it.matches('jo.{2}|JO.{2}')}.back(3).age ==>32
  • 24. # return path gremlin> g.v(1).outE.inV.name.paths ==>[v[1], e[7][1-knows->2], v[2], vadas] ==>[v[1], e[9][1-created->3], v[3], lop] ==>[v[1], e[8][1-knows->4], v[4], josh] gremlin> g.v(1).outE.inV.paths{it.name}{it.weight}{it.name} ==>[marko, 0.5, vadas] ==>[marko, 0.4, lop] ==>[marko, 1.0, josh]
  • 25. # loop gremlin> g.v(89).outE.inV.paths ==>[v[89], e[7021][89-followed_by->83], v[83]] ==>[v[89], e[7022][89-followed_by->21], v[21]] ==>[v[89], e[7006][89-followed_by->127], v[127]] ... gremlin> g.v(89).outE.inV.loop(2){it.loops < 3}.paths ==>[v[89], e[7021][89-followed_by->83], v[83], e[1411][83-followed_by->13], v[13]] ==>[v[89], e[7021][89-followed_by->83], v[83], e[1410][83-followed_by->12], v[12]] ==>[v[89], e[7021][89-followed_by->83], v[83], e[1415][83-followed_by->114], v[114]] ==>[v[89], e[7021][89-followed_by->83], v[83], e[1414][83-followed_by->15], v[15]] ... gremlin> g.v(89).outE.inV.loop(2){it.loops < 3} == g.v(89).outE.inV.outE.inV ==>true
  • 29. gremlin> g.v(1).out.name gremlin> ==>vadas g.v(1).out.name.paths ==>lop ==>[v[1], v[2], vadas] ==>josh ==>[v[1], v[3], lop] ==>[v[1], v[4], josh]
  • 30. gremlin> g.v(1).out('knows') ==>v[2] ==>v[4] gremlin> g.v(1).out('knows').filter{it.age < 30} ==>v[2] gremlin> g.v(1).out('knows').filter{it.age < 30}.name ==>vadas gremlin> g.v(1).out('knows').filter{it.age < 30}.name.transform{it.length()} ==>5
  • 31. gremlin> g.v(1).out('knows') ==>v[2] ==>v[4] gremlin> g.v(1).out('knows').filter{it.age < 30} ==>v[2] gremlin> g.v(1).out('knows').filter{it.age < 30}.name ==>vadas gremlin> g.v(1).out('knows').filter{it.age < 30}.name.transform{it.length()} ==>5
  • 32. gremlin> g.v(1).out('knows').ifThenElse{it.age < 30} {it.name}{it.out('created').name} ==>vadas ==>ripple ==>lop