Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

of

Graph Algebra Slide 1 Graph Algebra Slide 2 Graph Algebra Slide 3 Graph Algebra Slide 4 Graph Algebra Slide 5 Graph Algebra Slide 6 Graph Algebra Slide 7 Graph Algebra Slide 8 Graph Algebra Slide 9 Graph Algebra Slide 10 Graph Algebra Slide 11 Graph Algebra Slide 12 Graph Algebra Slide 13 Graph Algebra Slide 14 Graph Algebra Slide 15 Graph Algebra Slide 16 Graph Algebra Slide 17 Graph Algebra Slide 18 Graph Algebra Slide 19 Graph Algebra Slide 20 Graph Algebra Slide 21 Graph Algebra Slide 22 Graph Algebra Slide 23 Graph Algebra Slide 24 Graph Algebra Slide 25 Graph Algebra Slide 26 Graph Algebra Slide 27 Graph Algebra Slide 28 Graph Algebra Slide 29 Graph Algebra Slide 30 Graph Algebra Slide 31 Graph Algebra Slide 32 Graph Algebra Slide 33 Graph Algebra Slide 34 Graph Algebra Slide 35 Graph Algebra Slide 36 Graph Algebra Slide 37 Graph Algebra Slide 38 Graph Algebra Slide 39 Graph Algebra Slide 40 Graph Algebra Slide 41 Graph Algebra Slide 42 Graph Algebra Slide 43 Graph Algebra Slide 44 Graph Algebra Slide 45 Graph Algebra Slide 46 Graph Algebra Slide 47 Graph Algebra Slide 48 Graph Algebra Slide 49 Graph Algebra Slide 50 Graph Algebra Slide 51 Graph Algebra Slide 52 Graph Algebra Slide 53 Graph Algebra Slide 54 Graph Algebra Slide 55 Graph Algebra Slide 56 Graph Algebra Slide 57 Graph Algebra Slide 58 Graph Algebra Slide 59 Graph Algebra Slide 60
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

1 Like

Share

Download to read offline

Graph Algebra

Download to read offline

RedisGraph is the first queryable property graph database to use sparse adjacency matrices and linear algebra to represent and query graphs.

Graph Algebra

  1. 1. Graph AlgebraGraph Algebra
  2. 2. !2
  3. 3. Use casesUse cases
  4. 4. Realtime Recommendation
  5. 5. Fraud detection
  6. 6. Navigation & Traffic management Navigation & Traffic management
  7. 7. RedisGraph
  8. 8. ImplementationImplementation
  9. 9. Adjacency list
  10. 10. Adjacency matrix 0 0 1 1 0 1 0 0 0
  11. 11. Graph Algorithms in the language of Linear Algebra
  12. 12. !12 readth-first search example A(i, j) = 1 for edge (j, i) A is binary; dot (.) is zero for clarity . . . 1 . . . 1 . . . . . . . . . 1 . 1 1 1 . . . . . 1 . 1 . . . . 1 . . 1 . 1 . . . 1 . . . . . A(i, j) = 1 for edge ( A is binary; dot (.) is . . . 1 . . . 1 . . . . . . . . . 1 . 1 1 1 . . . . . 1 . 1 . . . . 1 . . 1 . 1 . . . 1 . . . . .
  13. 13. !13 h-first search: initializations v = zeros (n,1) ; // result q = false (n,1) ; // current level q (source) = true ; v: q: . . . . . . . 1 . . . . . . readth-first search example A(i, j) = 1 for edge (j, i) A is binary; dot (.) is zero for clarity . . . 1 . . . 1 . . . . . . . . . 1 . 1 1 1 . . . . . 1 . 1 . . . . 1 . . 1 . 1 . . . 1 . . . . .
  14. 14. !14 GrB assign (v, q, NULL, level, GrB ALL, n, NULL) v <q> = level ; // assig v: q: . . . . . . 1 1 . . . . . . gn (v, q, NULL, level, GrB ALL, n, NULL) v <q> = level ; // assign level v: q: . . . . . . 1 1 . . . . . .
  15. 15. !15 GrB mxv (q, v, NULL, GxB LOR LAND BOOL, A, q, desc) first part of q<!>=A*q: t = A*q ; xv (q, v, NULL, GxB LOR LAND BOOL, A, q, desc) first part of q<!>=A*q: t = A*q ;
  16. 16. !16 GrB mxv (q, v, NULL, GxB LOR LAND BOOL, A, q, desc) second part of q<!>=A*q: q = false (n,1) ; q <!v> = t ; v: t=A*q: q<!v>=t . 1 1 . . . . 1 1 1 . . . . . . . . . . . v (q, v, NULL, GxB LOR LAND BOOL, A, q, desc) second part of q<!>=A*q: q = false (n,1) ; q <!v> = t ; v: t=A*q: q<!v>=t . 1 1 . . . . 1 1 1 . . . . . . . . . . .
  17. 17. gn (v, q, NULL, level, GrB ALL, n, NULL) v <q> = level ; // assign level v: q: 2 1 . . 2 1 1 . . . . . . . GrB assign (v, q, NULL, level, GrB ALL, n, NULL) v <q> = level ; // a v: q: 2 1 . . 2 1 1 . . . . . . .
  18. 18. GrB mxv (q, v, NULL, GxB LOR LAND BOOL, A, q, desc first part of q<!>=A*q: t = A*q ; q, v, NULL, GxB LOR LAND BOOL, A, q, desc) first part of q<!>=A*q: t = A*q ;
  19. 19. Binary matrix 1 bit per matrix cell 1,000,000 X 1,000,000 One 10^12 (trillion) bits = 125GB ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. ………………………………………………………. !19
  20. 20. Real world graphs Most real world graphs are sparse Facebook 2 billion users 338 friends for user on average 2,000,000,000 * 338 / 2,000,000,000^2 0.000000169% utilisation !20
  21. 21. Sparse matrixSparse matrix
  22. 22. Graph BLAS Tim Davis John GilbertJeremy Kepner
  23. 23. GrB_Info GrB_mxm ( GrB_Matrix C, const GrB_Matrix Mask, const GrB_BinaryOp accum, const GrB_Semiring semiring, const GrB_Matrix A, const GrB_Matrix B, const GrB_Descriptor desc );
  24. 24. RedisGraph +
 GraphBLAS
  25. 25. Friend of a friend MATCH (src)-[:friend]->(f)-[:friend]->(foaf) WHERE src.age > 30 RETURN foaf src f foaf friend friend !25
  26. 26. Friend of a friend MATCH (src)-[:friend]->(f)-[:friend]->(foaf) WHERE src.age > 30 RETURN foaf src f foaf friend friend !26
  27. 27. Friend of a friend MATCH (src)-[:friend]->(f)-[:friend]->(foaf) WHERE src.age > 30 RETURN foaf src f foaf friend friend !27
  28. 28. Friend of a friend MATCH (src)-[:friend]->(f)-[:friend]->(foaf) WHERE src.age > 30 RETURN foaf src f foaf friend friend !28
  29. 29. Execution plan Index scan Expand Expand Project src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf !29
  30. 30. Execution plan Index scan Expand Expand Project !30 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  31. 31. Execution plan Index scan Expand Expand Project !31 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  32. 32. Execution plan Index scan Expand Expand Project !32 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  33. 33. Execution plan Index scan Expand Expand Project !33 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  34. 34. Execution plan Index scan Expand Expand Project !34 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  35. 35. Execution plan Index scan Expand Expand Project !35 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  36. 36. Execution plan Index scan Expand Expand Project !36 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  37. 37. Execution plan Index scan Expand Expand Project !37 src.age > 30 (src)-[:follows]->(f) (f)-[:follows]->(foaf) RETURN foaf
  38. 38. Cypher to Algebraic expressions
  39. 39. MATCH
 (src)-[:friend]->(f)-[:friend]->(foaf) WHERE src.age > 30 RETURN foaf = Age_Filter * Friendship * Friendship !39
  40. 40. 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Age Filter 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Friendships 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Friendships * * !40
  41. 41. Matrix multiplication is associative (A*B)*C = A*(B*C) !41
  42. 42. 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Friendships 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Friendships * 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 0 Friendships ^2 = number of none zero values = 18 !42
  43. 43. Age Filter 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Friendships 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 Filtered friendships
 src > 30 * = number of none zero values = 7 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 !43
  44. 44. 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Friendships 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 Filtered friendships
 src > 30 * = 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 FOF !44
  45. 45. 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 5 4 2 63 !45
  46. 46. 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 5 4 2 63 !46
  47. 47. Variable length MATCH (src)-[:friend*2..4]->(foaf) WHERE src.age > 30 RETURN foaf src F2 foaf friend F3 F4 !47
  48. 48. MATCH (src)-[:friend*2..4]->(foaf) WHERE src.age > 30 RETURN foaf = Age_Filter * (Friendship^2 + Friendship^3 + Friendship^4) 
 M = AF;
 R = 0;
 For i=0; i < 3; i++
 M = M*F
 R = R+M !48
  49. 49. bidirectional edge MATCH (A)-[:follows]-(B) RETURN A, B A B Knows !49
  50. 50. Follows + Follows^T !50
  51. 51. 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 Follows 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 Follows^T 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 1 1 0 0 0 1 1 1 0 0 Symmetric Follows + * !51
  52. 52. 1 5 4 2 63 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 1 1 0 0 0 1 1 1 0 0 !52
  53. 53. Graph distribution Block multiplication A*B=C A B C A1 A3 A4 A2 B1 B2 B4B3 C1 C2 C3 C4 !53
  54. 54. Graph distribution Block multiplication A*B=C A B C A1 A3 A4 A2 B1 B2 B4B3 A1*B1+
 A2*B3 A1*B2+
 A2*B4 A3*B1+
 A4*B3 A3*B2+
 A4*B4 !54
  55. 55. BenchmarksBenchmarks
  56. 56. Massive Insertion Workload !56 ~1M nodes, ~3M edges RedisGraph Titan OrientDB Neo4j Insert time in seconds 0 75 150 225 24.69 252.15 104.27 0.53
  57. 57. Find Neighbours !57 ~1M nodes, ~3M edges RedisGraph Titan OrientDB Neo4j Query processing time in seconds 0 7.5 15 22.5 4.51 9.34 20.71 0.05
  58. 58. Find Adjacent Nodes !58 ~1M nodes, ~3M edges RedisGraph Titan OrientDB Neo4j Query processing time in seconds 0 12.5 25 37.5 1.46 6.15 42.82 0.05
  59. 59. Shortest Path !59 ~1M nodes, ~3M edges RedisGraph Titan OrientDB Neo4j Query processing time in seconds 0 7.5 15 22.5 0.08 23.47 24.87 0.001
  60. 60. Thanks @roilipman
  • PetroRudenko

    Oct. 31, 2018

RedisGraph is the first queryable property graph database to use sparse adjacency matrices and linear algebra to represent and query graphs.

Views

Total views

1,530

On Slideshare

0

From embeds

0

Number of embeds

90

Actions

Downloads

10

Shares

0

Comments

0

Likes

1

×