• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
An Introduction to Tinkerpop
 

An Introduction to Tinkerpop

on

  • 31,695 views

 

Statistics

Views

Total Views
31,695
Views on SlideShare
6,085
Embed Views
25,610

Actions

Likes
12
Downloads
191
Comments
0

19 Embeds 25,610

http://www.graph-database.org 22543
http://graphdb.jp 1818
http://graph-you1025.blogspot.jp 751
http://graph-you1025.blogspot.com 233
http://graphdbjp.tumblr.com 85
http://graph-databases.org 45
http://translate.googleusercontent.com 28
http://paper.li 26
http://webcache.googleusercontent.com 26
http://a0.twimg.com 15
http://abtasty.com 12
http://us-w1.rockmelt.com 10
http://www.graph-databases.org 8
http://www.mefeedia.com 3
http://www.slideshare.net 2
http://graph-you1025.blogspot.kr 2
http://www.graph-database.org&_=1333885390943 HTTP 1
http://graph-you1025.blogspot.de 1
http://prlog.ru 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    An Introduction to Tinkerpop An Introduction to Tinkerpop Presentation Transcript

    • // An Exapmle of TinkerGraphGraph 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 jumpgremlin> v.outE.inV.outE.inV==>v[5]==>v[3]# shortcutgremlin> v.out.out==>v[5]==>v[3]# using filtergremlin> v.outE.filter{it.label==knows}.inV.filter{it.age >30}.name==>josh# backtracking and an in-line regular expressiongremlin> v.out(knows).filter{it.age >21}.name.filter{it.matches(jo.{2}|JO.{2})}.back(3).age==>32
    • # return pathgremlin> 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]
    • # loopgremlin> 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==>vadasgremlin> 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==>vadasgremlin> 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==>joshgremlin> g.v(1).out(knows).name.filter{it[0]==v}==>vadasgremlin>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]