Your SlideShare is downloading. ×
In The Land Of Graphs...
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

In The Land Of Graphs...

208
views

Published on

Scottland Ruby Conference 2014

Scottland Ruby Conference 2014

Published in: Technology, Self Improvement

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
208
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. In the land of graphs Fernand Galiana @kitesurfer
  • 2. Agenda • Graph morphology • Persistence mechanisms • Terminology • Modeling • Graph databases and API’s • Integrating with Ruby/Rails • How to win $1,000,000
  • 3. Graph Databases
  • 4. Morphology Dots and lines
  • 5. Undirected graph (~200BC)
  • 6. Directed graph (~14th-16th century)
  • 7. MultiRelational Graph (19th century) followsfollows likes likes
  • 8. Property Graph (present) followsfollows likes likes name: Fred age: 29 name: Jim age: 19
  • 9. Property Graph (cont) followsfollows likes likes name: Fred age: 29 name: James age: 19 weight: 0.9 date: 11/12/13
  • 10. @jimweirich
  • 11. Persistence
  • 12. Any database can model a graph
  • 13. Index Base Traversal DC E A B B,C E E,D CB D E A
  • 14. DC E A B B,C E E,D CB D E A Index Base Traversal
  • 15. DC E A B B,C E E,D CB D E A Index Base Traversal
  • 16. DC E A B B,C E E,D CB D E A Index Base Traversal
  • 17. A graph database is any storage system that can provide index-free adjacency.
  • 18. GraphDB DC E A B
  • 19. GraphDB DC E A B
  • 20. Performance Depth SQL Neo4j Recs 2 0.01 0.01 2.5k 3 30.26 0.16 100k 4 1,543 1.35 600k 5 Toast! 2.1 800k
  • 21. @jimweirich
  • 22. Why use a graph DB? • Recommendations - densifying the graph • Social • Ranking • Merging domains • Data analysis
  • 23. Terminology
  • 24. Terminology 1 2 follows 3 likes loves
  • 25. Terminology 1 2 follows 3 likes loves OUT Vertex IN Vertex
  • 26. Terminology 1 2 follows 3 likes loves vertex 1 OUT edges
  • 27. Terminology 1 2 follows 3 likes loves vertex 2 IN edges
  • 28. Terminology 1 2 follows 3 likes loves vertex 3 BOTH edges
  • 29. @jimweirich
  • 30. Modeling A B
  • 31. Modeling • Vertex • Edge • Properties • Relationships
  • 32. Modeling • Assess the space • Nodes = Entities • Edges = connections + semantic context • NProperties = entity attrs + meta • EProperties = strength + weight
  • 33. @jimweirich
  • 34. The Scene …
  • 35. DSLs • Cypher (Neo4j) • Gremlin (BluePrint) • SPARQL
  • 36. Rexster • Rexster (REST) • RexPro (bin) • Rexster Kibbles
  • 37. Blueprints
  • 38. Gremlin
  • 39. Gremlin[CruD] • g.addVertex(id,[a:10,b:’Hello’]) • g.addEdge(id,v1,v2,’friend’,[a:10]) • g.removeVertex(g.v(id)) • g.removeEdge(g.e(id)) • g.v(id).remove() • …
  • 40. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g = rexster.getGraph('derailed_graph')
  • 41. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.V ==> v[1], v[2], v[3], v[4], v[5], v[6], v[7]
  • 42. gremlin> g.E ==> e[1][1-friend-2], e[2][1-friend-3], etc… 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend
  • 43. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.v(1) ==> v[1]
  • 44. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.V(‘name’, ‘Gustave’) ==> v[1]
  • 45. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.e(1) ==> e[1][1-friend-2]
  • 46. gremlin> g.v(1).outE ==> e[1][1-friend-2], e[2][1-friend-3],e[3][1-friend-4] 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend
  • 47. gremlin> g.v(7).inE ==> e[7][3-friend-7] 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend
  • 48. gremlin> g.v(4).bothE ==> e[3][1-friend-4], e[8][4-friend-6] 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend
  • 49. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.v(4).both ==> v[1], v[6]
  • 50. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.v(1) ==> v[1]
  • 51. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.v(1).out(‘friend’) ==> v[2], v[3], v[4]
  • 52. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.v(1).out(‘friend’).out(‘friend’) ==> v[5], v[6], v[6], v[6], v[7]
  • 53. 2 4 5 6 7 1 3 Oscar Rango BatisteGustave Gertrude Stew Olaf friend friend friend friend friend friend friend friend gremlin> g.v(1).out(‘friend’).out(‘friend’).groupCount.cap ==> {v[5]=1,v[6]=3,v[7]=1}
  • 54. DEMO! • Rexster DogHouse • Wewoo
 (coz self promotion is underated!)
  • 55. @jimweirich
  • 56. Conclusion • Mining relationships • Recommendation, data analysis • Scoring, Ranking • Understand problem space • Search engine integration • Combining several problem spaces
  • 57. References • https://github.com/tinkerpop/gremlin • http://gremlindocs.com • http://sql2gremlin.com • github.com/derailed/wewoo • @jimweirich
  • 58. Is a Graph worth a thousand joins? ! ! ! Thank you! @kitesurfer fernand.galiana@gmail.com