In the land of graphs
Fernand Galiana
@kitesurfer
Agenda
• Graph morphology
• Persistence mechanisms
• Terminology
• Modeling
• Graph databases and API’s
• Integrating with...
Graph Databases
Morphology
Dots and lines
Undirected graph
(~200BC)
Directed graph
(~14th-16th century)
MultiRelational Graph
(19th century)
followsfollows
likes
likes
Property Graph
(present)
followsfollows
likes
likes
name: Fred
age: 29
name: Jim
age: 19
Property Graph (cont)
followsfollows
likes
likes
name: Fred
age: 29
name: James
age: 19
weight: 0.9
date: 11/12/13
@jimweirich
Persistence
Any database can model a graph
Index Base Traversal
DC
E
A
B
B,C E E,D
CB
D E
A
DC
E
A
B
B,C E E,D
CB
D E
A
Index Base Traversal
DC
E
A
B
B,C E E,D
CB
D E
A
Index Base Traversal
DC
E
A
B
B,C E E,D
CB
D E
A
Index Base Traversal
A graph database is any storage system that
can provide index-free adjacency.
GraphDB
DC
E
A
B
GraphDB
DC
E
A
B
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
@jimweirich
Why use a graph DB?
• Recommendations - densifying the graph
• Social
• Ranking
• Merging domains
• Data analysis
Terminology
Terminology
1 2
follows
3
likes
loves
Terminology
1 2
follows
3
likes
loves
OUT Vertex IN Vertex
Terminology
1 2
follows
3
likes
loves
vertex 1 OUT edges
Terminology
1 2
follows
3
likes
loves
vertex 2 IN edges
Terminology
1 2
follows
3
likes
loves
vertex 3 BOTH edges
@jimweirich
Modeling
A B
Modeling
• Vertex
• Edge
• Properties
• Relationships
Modeling
• Assess the space
• Nodes = Entities
• Edges = connections + semantic context
• NProperties = entity attrs + met...
@jimweirich
The Scene
…
DSLs
• Cypher (Neo4j)
• Gremlin (BluePrint)
• SPARQL
Rexster
• Rexster (REST)
• RexPro (bin)
• Rexster Kibbles
Blueprints
Gremlin
Gremlin[CruD]
• g.addVertex(id,[a:10,b:’Hello’])
• g.addEdge(id,v1,v2,’friend’,[a:10])
• g.removeVertex(g.v(id))
• g.remov...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
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
frie...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
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
Gert...
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
...
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
f...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
2
4
5
6
7
1 3
Oscar
Rango
BatisteGustave
Gertrude
Stew
Olaf
friend
friend
friend
friend
friend
friend
friend
friend
gremli...
DEMO!
• Rexster DogHouse
• Wewoo

(coz self promotion is underated!)
@jimweirich
Conclusion
• Mining relationships
• Recommendation, data analysis
• Scoring, Ranking
• Understand problem space
• Search e...
References
• https://github.com/tinkerpop/gremlin
• http://gremlindocs.com
• http://sql2gremlin.com
• github.com/derailed/...
Is a Graph worth a thousand joins?
!
!
!
Thank you!
@kitesurfer
fernand.galiana@gmail.com
In The Land Of Graphs...
In The Land Of Graphs...
In The Land Of Graphs...
Upcoming SlideShare
Loading in …5
×

In The Land Of Graphs...

369
-1

Published on

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
369
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

In The Land Of Graphs...

  1. 1. In the land of graphs Fernand Galiana @kitesurfer
  2. 2. Agenda • Graph morphology • Persistence mechanisms • Terminology • Modeling • Graph databases and API’s • Integrating with Ruby/Rails • How to win $1,000,000
  3. 3. Graph Databases
  4. 4. Morphology Dots and lines
  5. 5. Undirected graph (~200BC)
  6. 6. Directed graph (~14th-16th century)
  7. 7. MultiRelational Graph (19th century) followsfollows likes likes
  8. 8. Property Graph (present) followsfollows likes likes name: Fred age: 29 name: Jim age: 19
  9. 9. Property Graph (cont) followsfollows likes likes name: Fred age: 29 name: James age: 19 weight: 0.9 date: 11/12/13
  10. 10. @jimweirich
  11. 11. Persistence
  12. 12. Any database can model a graph
  13. 13. Index Base Traversal DC E A B B,C E E,D CB D E A
  14. 14. DC E A B B,C E E,D CB D E A Index Base Traversal
  15. 15. DC E A B B,C E E,D CB D E A Index Base Traversal
  16. 16. DC E A B B,C E E,D CB D E A Index Base Traversal
  17. 17. A graph database is any storage system that can provide index-free adjacency.
  18. 18. GraphDB DC E A B
  19. 19. GraphDB DC E A B
  20. 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. 21. @jimweirich
  22. 22. Why use a graph DB? • Recommendations - densifying the graph • Social • Ranking • Merging domains • Data analysis
  23. 23. Terminology
  24. 24. Terminology 1 2 follows 3 likes loves
  25. 25. Terminology 1 2 follows 3 likes loves OUT Vertex IN Vertex
  26. 26. Terminology 1 2 follows 3 likes loves vertex 1 OUT edges
  27. 27. Terminology 1 2 follows 3 likes loves vertex 2 IN edges
  28. 28. Terminology 1 2 follows 3 likes loves vertex 3 BOTH edges
  29. 29. @jimweirich
  30. 30. Modeling A B
  31. 31. Modeling • Vertex • Edge • Properties • Relationships
  32. 32. Modeling • Assess the space • Nodes = Entities • Edges = connections + semantic context • NProperties = entity attrs + meta • EProperties = strength + weight
  33. 33. @jimweirich
  34. 34. The Scene …
  35. 35. DSLs • Cypher (Neo4j) • Gremlin (BluePrint) • SPARQL
  36. 36. Rexster • Rexster (REST) • RexPro (bin) • Rexster Kibbles
  37. 37. Blueprints
  38. 38. Gremlin
  39. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 54. DEMO! • Rexster DogHouse • Wewoo
 (coz self promotion is underated!)
  55. 55. @jimweirich
  56. 56. Conclusion • Mining relationships • Recommendation, data analysis • Scoring, Ranking • Understand problem space • Search engine integration • Combining several problem spaces
  57. 57. References • https://github.com/tinkerpop/gremlin • http://gremlindocs.com • http://sql2gremlin.com • github.com/derailed/wewoo • @jimweirich
  58. 58. Is a Graph worth a thousand joins? ! ! ! Thank you! @kitesurfer fernand.galiana@gmail.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×