Successfully reported this slideshow.

The Pathology of Graph Databases

37

Share

Upcoming SlideShare
Introduction to Gremlin
Introduction to Gremlin
Loading in …3
×
1 of 240
1 of 240

The Pathology of Graph Databases

37

Share

Download to read offline

There is nothing more fascinating and utterly mind-bending than traversing a graph. Those who succumb to this data processing pattern euphorically suffer from graph pathology.

This is a case study of the Graph Addict.

There is nothing more fascinating and utterly mind-bending than traversing a graph. Those who succumb to this data processing pattern euphorically suffer from graph pathology.

This is a case study of the Graph Addict.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

The Pathology of Graph Databases

  1. 1. The Pathology of Graph Databases Marko A. Rodriguez Graph Systems Architect http://markorodriguez.com http://twitter.com/twarko http://tinkerpop.com TinkerPop WindyCityDB - Chicago, Illinois – June 25, 2011
  2. 2. Abstract There is nothing more fascinating and utterly mind- bending than traversing a graph. Those who succumb to this data processing pattern euphorically suffer from graph pathology. This is a case study of the Graph Addict. Gremlin G = (V, E) What is presented is as of Gremlin 1.1 (Released July 15, 2011)
  3. 3. What you are about to see may disturb you. It has infected Neo4j, OrientDB, DEX, RDF Sail, TinkerGraph, and ReXster. reXster ...it will infect others.
  4. 4. ? ? ?
  5. 5. ~$ cd /tmp/graphdb
  6. 6. graphdb$ gremlin
  7. 7. ,,,/ (o o) -----o00o(_)-o00o----- gremlin>
  8. 8. The Basics
  9. 9. Gremlin is a Groovy DSL and as such, has native JVM access. 'Gremlin is a Groovy DSL and as such, has native JVM access.'
  10. 10. 3 1+2
  11. 11. gremlin 'gremlin'
  12. 12. emlin 'gremlin'.substring(2)
  13. 13. [1,2,3,4,5] list = [1,2,3,4,5]
  14. 14. key1=value key2=123 map = [key1:'value',key2:123]
  15. 15. <modem sound/> socket = new Socket('127.0.0.1',8182)
  16. 16. true TextAnalysis.isMean('You are that which is not good.')
  17. 17. Graph Traversing
  18. 18. /tmp/graphdb g = new Neo4jGraph('/tmp/graphdb')
  19. 19. /tmp/graphdb g
  20. 20. 1 g.v(1)
  21. 21. name=marko 1 g.v(1).name
  22. 22. 1 g.v(1)
  23. 23. city=santafe 1 g.v(1).city
  24. 24. 1 g.v(1)
  25. 25. name=marko city=santafe 1 g.v(1).map()
  26. 26. 1 g.v(1)
  27. 27. created 1 knows knows g.v(1).outE
  28. 28. created 1 knows knows g.v(1).outE
  29. 29. null created since=2010 1 knows since=2005 knows g.v(1).outE.since
  30. 30. created 1 knows knows g.v(1).outE
  31. 31. 2 created 1 knows 3 knows 4 g.v(1).outE.inV
  32. 32. 2 name=rexster created 1 knows 3 name=stephen knows 4 name=peter g.v(1).outE.inV.name
  33. 33. /tmp/graphdb g
  34. 34. 1 g.v(1)
  35. 35. created 1 knows knows g.v(1).outE
  36. 36. created 1 knows knows g.v(1).outE[[label:'knows']]
  37. 37. 1 g.v(1)
  38. 38. created 1 knows knows g.v(1).outE
  39. 39. created 1 knows knows g.v(1).outE.filter{it.label=='knows'}
  40. 40. 2 g.v(1).outE.filter{it.label=='knows'}.count()
  41. 41. created 1 knows knows g.v(1).outE
  42. 42. created 1 knows knows g.v(1).outE.filter{it.label=='knows' & since > 2006}
  43. 43. [OutEdgesPipe, LabelFilterPipe(NOT_EQUAL,knows), InVertexPipe] g.v(1).outE[[label:'knows']].inV.toString()
  44. 44. 1 g.v(1)
  45. 45. 1 knows knows g.v(1).outE('knows')
  46. 46. 1 knows 3 knows 4 g.v(1).outE('knows').inV
  47. 47. [OutEdgesPipe(knows), InVertexPipe] g.v(1).outE('knows').inV.toString()
  48. 48. 1 g.v(1)
  49. 49. 1 knows 3 knows 4 g.v(1).out('knows')
  50. 50. 1 knows 3 name=stephen knows 4 name=peter g.v(1).out('knows').name
  51. 51. 1 knows 3 name=stephen knows 4 name=peter g.v(1).out('knows').name.filter{it.startsWith('st')}
  52. 52. 1 knows 3 name=stephen knows 4 name=peter g.v(1).out('knows').name.filter{it.matches('p.{4}')}
  53. 53. 1 knows 3 name=stephen knows 4 name=peter g.v(1).out('knows').name.filter{it.matches('p.{4}') & false}
  54. 54. [OutPipe(knows)] g.v(1).out('knows').toString()
  55. 55. 1 g.v(1)
  56. 56. o o! o oH W 1 g.v(1).filter{new Random().nextBoolean()}
  57. 57. 1 g.v(1)
  58. 58. t! A lrigh 1 g.v(1).filter{new Random().nextBoolean()}
  59. 59. 1 g.v(1)
  60. 60. Doh! 1 g.v(1).filter{new Random().nextBoolean()}
  61. 61. 1
  62. 62. 1
  63. 63. 1
  64. 64. 1
  65. 65. Graph Inference
  66. 66. 1 g.v(1)
  67. 67. 2 created 1 g.v(1).out('created')
  68. 68. 2 name=rexster created 1 g.v(1).out('created').name
  69. 69. 1 g.v(1)
  70. 70. 2 created 1 g.v(1).out('created')
  71. 71. 2 created created 1 3 g.v(1).out('created').in('created')
  72. 72. 2 created created 1 3 g.v(1).out('created').in('created').except([g.v(1)])
  73. 73. 2 created created 1 3 name=stephen g.v(1).out('created').in('created').except([g.v(1)]).name
  74. 74. 2 created created 1 3 name=stephen g.v(1).out('created').in('created').except([g.v(1)]).name.back(1)
  75. 75. 2 created created 1 collaborator 3 name=stephen g.v(1).out('created').in('created').except([g.v(1)]).name.back(1). sideEffect{g.addEdge(g.v(1),it,'collaborator')}
  76. 76. 2 created created 1 collaborator 3 name=stephen g.v(1).out('created').in('created').except([g.v(1)]).name.back(1). sideEffect{g.addEdge(g.v(1),it,'collaborator')}.filter{false}
  77. 77. Graph Backtracking and Looping
  78. 78. 1 g.v(1)
  79. 79. 2 created 1 g.v(1).out('created')
  80. 80. 5 imports 2 imports 6 imports created 7 1 g.v(1).out('created').out('imports')
  81. 81. 5 name=blueprints imports 2 imports 6 name=pipes imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name
  82. 82. 5 name=blueprints imports 2 imports 6 name=pipes imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1)
  83. 83. 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports')
  84. 84. 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports')
  85. 85. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports').name
  86. 86. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports').name .back(1)
  87. 87. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports').name .back(1).out('imports')
  88. 88. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports').name .back(1).out('imports').out('imports')
  89. 89. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').name.back(1).out('imports').name .back(1).out('imports').out('imports').out('imports')
  90. 90. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  91. 91. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  92. 92. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  93. 93. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  94. 94. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  95. 95. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  96. 96. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  97. 97. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 2 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  98. 98. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 3 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  99. 99. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 4 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  100. 100. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('imports').loop(1){it.loops < 5}
  101. 101. m m = [:]
  102. 102. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  103. 103. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  104. 104. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  105. 105. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  106. 106. v[5]=1 m v[6]=1 v[7]=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  107. 107. v[5]=1 m v[6]=1 v[7]=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  108. 108. v[5]=3 v[6]=2 m v[7]=1 v[8]=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  109. 109. v[5]=3 v[6]=2 m v[7]=1 v[8]=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  110. 110. v[5]=4 v[6]=2 m v[7]=1 v[8]=3 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  111. 111. v[5]=4 v[6]=2 m v[7]=1 v[8]=3 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  112. 112. v[5]=4 v[6]=2 m v[7]=1 v[8]=4 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  113. 113. v[5]=4 v[6]=2 m v[7]=1 v[8]=4 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').groupCount(m).loop(2){true}
  114. 114. m m = [:]
  115. 115. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  116. 116. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  117. 117. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  118. 118. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  119. 119. m name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  120. 120. blueprints=1 m pipes=1 gremlin=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  121. 121. blueprints=1 m pipes=1 gremlin=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  122. 122. blueprints=1 m pipes=1 gremlin=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  123. 123. blueprints=1 m pipes=1 gremlin=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  124. 124. blueprints=3 pipes=2 m gremlin=1 neo4j=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  125. 125. blueprints=3 pipes=2 m gremlin=1 neo4j=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  126. 126. blueprints=3 pipes=2 m gremlin=1 neo4j=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  127. 127. blueprints=3 pipes=2 m gremlin=1 neo4j=1 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  128. 128. blueprints=4 pipes=2 m gremlin=1 neo4j=3 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  129. 129. blueprints=4 pipes=2 m gremlin=1 neo4j=3 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  130. 130. blueprints=4 pipes=2 m gremlin=1 neo4j=3 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  131. 131. blueprints=4 pipes=2 m gremlin=1 neo4j=3 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  132. 132. blueprints=4 pipes=2 m gremlin=1 neo4j=4 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  133. 133. blueprints=4 pipes=2 m gremlin=1 neo4j=4 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  134. 134. blueprints=4 pipes=2 m gremlin=1 neo4j=4 name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').out('import').name.groupCount(m).back(2).loop(2){true}
  135. 135. Graph Paths
  136. 136. 1 g.v(1)
  137. 137. 1 g.v(1).as('x')
  138. 138. 9 10 child child 1 g.v(1).as('x').in('child')
  139. 139. 9 10 child child 1 g.v(1).as('x').in('child').loop('x')
  140. 140. child child 9 10 child child 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}
  141. 141. child child child child 9 10 child child 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}
  142. 142. child child child child child child 9 10 child child 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}
  143. 143. 100,000,000 100,000,001 child child ... ... child child child child child child 9 10 child child 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}
  144. 144. 100,000,000 100,000,001 child child ... ... child child child child child child 9 10 child child [v[1], v[9], ..., v[100,000,000]] [v[1], v[10], ..., v[100,000,001]] ... 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}.paths
  145. 145. name=angelina name=brad 100,000,000 100,000,001 child child ... ... child child child child child child 9 10 child child 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}.name
  146. 146. name=angelina name=brad 100,000,000 100,000,001 child child ... ... child child child child child child 9 10 child child [v[1], v[9], ..., v[100,000,000], angelina] [v[1], v[10], ..., v[100,000,001], brad] ... 1 g.v(1).as('x').in('child').loop('x'){it.object.in.count() != 0}.name.paths
  147. 147. 1 g.v(1)
  148. 148. child child 1 g.v(1).inE('child')
  149. 149. thinks="You suck." thinks="You're great." child child 1 g.v(1).inE('child').filter{TextAnalysis.isMean(it.thinks)}
  150. 150. thinks="You suck." child 1 g.v(1).inE('child').filter{TextAnalysis.isMean(it.thinks)}
  151. 151. 9 thinks="You suck." child 1 g.v(1).inE('child').filter{TextAnalysis.isMean(it.thinks)}.outV
  152. 152. irl." ag w like thro ou ks="Y thin thinks="No pony!" thi n ks ="Y ou 're fat ." thinks="Get a real job." 9 thinks="You suck." child 1 g.v(1).inE('child').filter{TextAnalysis.isMean(it.thinks)}.outV.loop(3){true}
  153. 153. irl." ag w like thro ou ks="Y thin thinks="No pony!" thi n ks ="Y ou 're fat ." thinks="Get a real job." 9 thinks="You suck." child 1 g.v(1).inE('child').filter{TextAnalysis.isMean(it.thinks)}.outV.loop(3){true}
  154. 154. Graph Pattern Matching
  155. 155. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  156. 156. SELECT ?x ?y WHERE { 1 created ?x . ?x imports ?y } name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  157. 157. SELECT ?x ?y WHERE { 1 created ?x . ?x imports ?y } name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  158. 158. SELECT ?x ?y WHERE { 1 created ?x . ?x imports ?y } name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  159. 159. SELECT ?x ?y WHERE { ?x ?y 1 created ?x . v[2] v[5] v[2] v[6] ?x imports ?y v[2] v[7] } name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  160. 160. name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1
  161. 161. t name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 t = new Table()
  162. 162. t name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1)
  163. 163. t name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created')
  164. 164. t name=neo4j 8 imports 5 name=blueprints imports imports x imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').as('x')
  165. 165. t name=neo4j 8 imports 5 name=blueprints imports imports x imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').as('x').out('imports')
  166. 166. t name=neo4j 8 imports y 5 name=blueprints imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 g.v(1).out('created').as('x').out('imports').as('y')
  167. 167. x y v[2] v[5] t v[2] v[6] v[2] v[7] name=neo4j 8 imports y 5 name=blueprints imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 g.v(1).out('created').as('x').out('imports').as('y').table(t)
  168. 168. x y v[2] v[5] t v[2] v[6] v[2] v[7] name=neo4j 8 imports y 5 name=blueprints v[5] imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 t.get(0,1)
  169. 169. x y v[2] v[5] t v[2] v[6] v[2] v[7] name=neo4j 8 imports y 5 name=blueprints v[2] imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 t.get(0,'x')
  170. 170. x y v[2] v[5] t v[2] v[6] v[2] v[7] name=neo4j 8 imports y 5 name=blueprints v[5] v[6] imports v[7] y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 t.getColumn('y')
  171. 171. x y v[2] v[5] t v[2] v[6] v[2] v[7] name=neo4j 8 imports y 5 name=blueprints [x, y] imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 t.getColumnNames()
  172. 172. t name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 t = new Table()
  173. 173. t name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1)
  174. 174. t name=neo4j 8 imports 5 name=blueprints imports imports imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created')
  175. 175. t name=neo4j 8 imports 5 name=blueprints imports imports x imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').as('x')
  176. 176. t name=neo4j 8 imports 5 name=blueprints imports imports x imports 2 imports 6 name=pipes imports imports created 7 name=gremlin 1 g.v(1).out('created').as('x').out('imports')
  177. 177. t name=neo4j 8 imports y 5 name=blueprints imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 g.v(1).out('created').as('x').out('imports').as('y')
  178. 178. x y 2 blueprints t 2 pipes 2 gremlin name=neo4j 8 imports y 5 name=blueprints imports y imports x imports 2 imports 6 name=pipes imports y imports created 7 name=gremlin 1 g.v(1).out('created').as('x').out('imports').as('y').table(t){it.id}{it.name}
  179. 179. g.clear()
  180. 180. Graph Construction
  181. 181. 1 a = g.addVertex()
  182. 182. name=pierre 1 a.name = 'pierre'
  183. 183. name=pierre city=brussels 1 a.city = 'brussels'
  184. 184. name=stephen city=dc 2 name=pierre city=brussels 1 b = g.addVertex([name:'stephen',city:'dc'])
  185. 185. name=rexster logo= reXster . 3 name=stephen city=dc 2 name=pierre city=brussels 1 c = g.addVertex([name:'rexster',logo:[a12f04b312bc...]])
  186. 186. name=rexster logo= reXster . 3 since=2011 created name=stephen city=dc 2 name=pierre city=brussels 1 g.addEdge(b,c,'created',[since:2011])
  187. 187. name=rexster logo= reXster . 3 since=2011 created name=stephen since=2011 city=dc reviews 2 name=pierre city=brussels 1 g.addEdge(a,c,'reviews',[since:2011])
  188. 188. name=gremlin logo= Gremlin G = (V, E) . 4 name=rexster imports logo= reXster . 3 since=2011 created name=stephen since=2011 city=dc reviews 2 name=pierre city=brussels 1 g.addEdge(c,g.addVertex([name:'gremlin',logo:[ab1346f47...]),'imports')
  189. 189. name=pipes logo= Pipes. 5 name=gremlin logo= Gremlin G = (V, E) . imports 4 name=rexster imports logo= reXster . 3 since=2011 created name=stephen since=2011 city=dc reviews 2 name=pierre city=brussels 1 g.addEdge(c,g.addVertex([name:'pipes',logo:[12cbef46...]]),'imports')
  190. 190. name=blueprints name=pipes logo= Blueprints . logo= Pipes. 6 5 name=gremlin logo= Gremlin imports . G = (V, E) imports 4 name=rexster imports logo= reXster . 3 since=2011 created name=stephen since=2011 city=dc reviews 2 name=pierre city=brussels 1 g.addEdge(c,g.addVertex([name:'blueprints',logo:[f13cd1467...]]),'imports')
  191. 191. 6 5 4 3 2 1 g.V
  192. 192. 6 g.V.count()
  193. 193. blueprints pipes gremlin rexster stephen pierre g.V.name
  194. 194. 6 5 4 3 2 1 g.V
  195. 195. Blueprints Pipes Gremlin G = (V, E) reXster g.V.logo
  196. 196. 4 g.V.logo.count()
  197. 197. name=blueprints name=pipes logo= Blueprints . logo= Pipes . name=gremlin logo= Gremlin G = (V, E) . name=rexster logo= reXster . name=stephen city=dc name=pierre city=brussels g.V.transform{it.map()}
  198. 198. 6 g.V.transform{it.map()}.count()
  199. 199. 7 g.V.transform{it.map()}.count() + 1
  200. 200. 8 g.V.transform{it.map()}.count() + 1 + 1
  201. 201. 4 (g.V.transform{it.map()}.count() + 1 + 1) / 2
  202. 202. 4 is a number. ((g.V.transform{it.map()}.count() + 1 + 1) / 2) + ' is a number.'
  203. 203. 14 (((g.V.transform{it.map()}.count() + 1 + 1) / 2) + ' is a number.').length()
  204. 204. imports imports imports created reviews g.E
  205. 205. since=2011 since=2011 g.E.transform{it.map()}
  206. 206. g.clear()
  207. 207. Graph Ranking
  208. 208. 7 friend 6 friend friend 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.loadGraphML('loopy-lou-and-the-loops.xml')
  209. 209. m 7 friend 6 friend friend 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 m = [:]
  210. 210. m 7 friend 6 friend friend c 0 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 c = 0
  211. 211. m 7 friend 6 friend friend c 0 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  212. 212. m 7 friend 6 friend friend c 0 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  213. 213. v[2]=1 m v[6]=1 7 friend 6 friend friend c 0 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  214. 214. v[2]=1 m v[6]=1 7 friend 6 friend friend c 2 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  215. 215. v[2]=1 v[3]=1 m v[6]=2 v[7]=1 7 friend 6 friend friend c 2 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  216. 216. v[2]=1 v[3]=1 m v[6]=2 v[7]=1 7 friend 6 friend friend c 5 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  217. 217. v[1]=1 v[2]=1 v[3]=1 m v[4]=1 v[6]=2 v[7]=2 v[8]=1 7 friend 6 friend friend c 5 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  218. 218. v[1]=1 v[2]=1 v[3]=1 m v[4]=1 v[6]=2 v[7]=2 v[8]=1 7 friend 6 friend friend c 9 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  219. 219. v[1]=3 v[2]=2 v[3]=1 v[4]=1 m v[5]=1 v[6]=3 v[7]=2 v[8]=2 7 friend 6 friend friend c 9 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  220. 220. v[1]=3 v[2]=2 v[3]=1 v[4]=1 m v[5]=1 v[6]=3 v[7]=2 v[8]=2 7 friend 6 friend friend c 15 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  221. 221. v[1]=4 v[2]=4 v[3]=3 v[4]=1 m v[5]=1 v[6]=7 v[7]=3 v[8]=2 7 friend 6 friend friend c 15 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  222. 222. v[1]=4 v[2]=4 v[3]=3 v[4]=1 m v[5]=1 v[6]=7 v[7]=3 v[8]=2 7 friend 6 friend friend c 25 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  223. 223. v[1]=5 v[2]=5 v[3]=5 v[4]=3 m v[5]=1 v[6]=10 v[7]=7 v[8]=3 7 friend 6 friend friend c 25 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  224. 224. v[1]=5 v[2]=5 v[3]=5 v[4]=3 m v[5]=1 v[6]=10 v[7]=7 v[8]=3 7 friend 6 friend friend c 39 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  225. 225. v[1]=5 v[2]=5 v[3]=5 v[4]=3 m v[5]=1 v[6]=10 v[7]=7 v[8]=3 7 friend 6 friend friend c 39 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 g.v(1).out.groupCount(m).loop(2){c++ < 35}.filter{false}
  226. 226. v[1]=5 v[2]=5 v[3]=5 v[4]=3 m v[5]=1 v[6]=10 v[7]=7 v[8]=3 7 friend 6 friend friend c 39 8 5 friend friend friend friend friend friend 1 4 friend friend 2 friend 3 println 'do you understand the concept of centrality?'
  227. 227. g.clear()
  228. 228. IDE Development reXster Command Line REPL REST Server
  229. 229. Via any JVM language (JSR 223) Neo4j Server
  230. 230. http://gremlin.tinkerpop.com

×