SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
// 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]
...
{
                                                 "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
}
~$ gremlin


           ,,,/
           (o o)
-----oOOo-(_)-oOOo-----
gremlin>
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
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

Weitere ähnliche Inhalte

Was ist angesagt?

Travel management
Travel managementTravel management
Travel management
1Parimal2
 
Paperjs presentation
Paperjs presentationPaperjs presentation
Paperjs presentation
sharp-blade
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
hayato
 

Was ist angesagt? (19)

Introduzione a C#
Introduzione a C#Introduzione a C#
Introduzione a C#
 
Ping pong game
Ping pong  gamePing pong  game
Ping pong game
 
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
 
MongoDB
MongoDBMongoDB
MongoDB
 
Travel management
Travel managementTravel management
Travel management
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 
Paperjs presentation
Paperjs presentationPaperjs presentation
Paperjs presentation
 
Cquestions
Cquestions Cquestions
Cquestions
 
Include
IncludeInclude
Include
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Implementing string
Implementing stringImplementing string
Implementing string
 
Exp3
Exp3Exp3
Exp3
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
2. Базовый синтаксис Java
2. Базовый синтаксис Java2. Базовый синтаксис Java
2. Базовый синтаксис Java
 
Circular queue
Circular queueCircular queue
Circular queue
 
Vcs9
Vcs9Vcs9
Vcs9
 
2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 

Ähnlich wie An Introduction to Tinkerpop

MongoDB Analytics
MongoDB AnalyticsMongoDB Analytics
MongoDB Analytics
datablend
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
Lei Kang
 
Tips and Tricks for Avoiding Common Query Pitfalls
Tips and Tricks for Avoiding Common Query PitfallsTips and Tricks for Avoiding Common Query Pitfalls
Tips and Tricks for Avoiding Common Query Pitfalls
MongoDB
 
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
ConFoo
 
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
Takahiro Inoue
 

Ähnlich wie An Introduction to Tinkerpop (20)

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

Mehr von Takahiro Inoue

Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界
Takahiro Inoue
 
20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション
Takahiro Inoue
 
トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方
Takahiro Inoue
 
オンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータオンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータ
Takahiro Inoue
 
事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612
Takahiro Inoue
 
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
Takahiro Inoue
 
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
Takahiro Inoue
 
Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!
Takahiro Inoue
 
Hadoop and the Data Scientist
Hadoop and the Data ScientistHadoop and the Data Scientist
Hadoop and the Data Scientist
Takahiro Inoue
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
Takahiro Inoue
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB Plugins
Takahiro Inoue
 
An Introduction to Neo4j
An Introduction to Neo4jAn Introduction to Neo4j
An Introduction to Neo4j
Takahiro Inoue
 
The Definition of GraphDB
The Definition of GraphDBThe Definition of GraphDB
The Definition of GraphDB
Takahiro Inoue
 

Mehr von Takahiro Inoue (20)

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

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

An Introduction to Tinkerpop

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 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] ...
  • 12.
  • 13.
  • 14.
  • 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 }
  • 17.
  • 18. ~$ gremlin ,,,/ (o o) -----oOOo-(_)-oOOo----- gremlin>
  • 19.
  • 20.
  • 21.
  • 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
  • 26.
  • 27.
  • 28.
  • 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