Graphs, Databases and what we can use them for
Michael Hackstein
@mchacki

November 6, 2013

c 2013 triAGENS GmbH | 2013-1...
About me

Still Student (Master Informatik) at RWTH
Just handed in my thesis
Software developer at triAGENS GmbH, CGN
Part...
Table of contents

1 Definition
2 Use Cases
3 Databases
4 Traversals
5 Visualisation

c 2013 triAGENS GmbH | 2013-11-6
What is a graph?
A set of arbitrary objects, called vertices

c 2013 triAGENS GmbH | 2013-11-6
What is a graph?
A set of arbitrary objects, called vertices
And a set of relations between them, called edges

c 2013 tri...
Formal Definition

Let V be the set of vertices
Let E ⊆ V × V be the set of edges
Define G = (V , E ) is a graph

c 2013 tri...
Formal Definition

Let V be the set of vertices
Let E ⊆ V × V be the set of edges
Define G = (V , E ) is a graph
Define δ + (...
Directed Graphs
Edges have a direction
One vertex is the source
The other vertex is the target
Formal: (a, b) ∈ E
(b, a) ∈...
Example: Navigation Systems

c 2013 triAGENS GmbH | 2013-11-6
Undirected Graphs
Edges do not have a direction
No vertex is source or target
Formal: (a, b) ∈ E ⇔ (b, a) ∈ E
And (a, b) ∈...
Example: Social Networks

Charly
Diana

Bob
Alice

c 2013 triAGENS GmbH | 2013-11-6
Property Graphs
Vertices have properties in addition to a label
Edges have properties in addition to a label

c 2013 triAG...
Graphs in Relational Databases

m
Edge

Vertex
n

c 2013 triAGENS GmbH | 2013-11-6
Where else to store Graphs?

c 2013 triAGENS GmbH | 2013-11-6
How to store Graphs?

We will have an example using ArangoDB.
First Example: Create new database using Graphs API
DEMO TIM...
How to store Graphs?

Second Example: You already have vertices.
How to add edges?
DEMO TIME

c 2013 triAGENS GmbH | 2013-...
But what can we do with the data now?

c 2013 triAGENS GmbH | 2013-11-6
Queries on graphs

Mechanism to query a graph
Starts at one specific vertex
Searches all connected vertices
Searches childr...
The visitor

Active at each searched vertex
Can execute queries on this vertex like collecting attributes
Does know the pa...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals
Grain: 0
Nuts: 0

Grain: 2
Nuts: 3

Grain: 0
Nuts: 2
Grain: 1
Nuts: 1

Grain: 2
Nuts: 0
Grain: 5
Nuts: 5

Grain...
Traversals Live

Example: Execute traversal in ArangoDB
DEMO TIME

c 2013 triAGENS GmbH | 2013-11-6
Visualisation

Example: How to view the graph
DEMO TIME

c 2013 triAGENS GmbH | 2013-11-6
Nächste SlideShare
Wird geladen in …5
×

GraphDatabases and what we can use them for

1.088 Aufrufe

Veröffentlicht am

In this talk the general idea of graph databases is presented and the execution of a graph traversal is shown.
The talk has been given at NoSQL UG Cologne (in Nov. 2013)

Veröffentlicht in: Technologie, Business, Unterhaltung & Humor
0 Kommentare
0 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Keine Downloads
Aufrufe
Aufrufe insgesamt
1.088
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
2
Aktionen
Geteilt
0
Downloads
8
Kommentare
0
Gefällt mir
0
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie

GraphDatabases and what we can use them for

  1. 1. Graphs, Databases and what we can use them for Michael Hackstein @mchacki November 6, 2013 c 2013 triAGENS GmbH | 2013-11-6
  2. 2. About me Still Student (Master Informatik) at RWTH Just handed in my thesis Software developer at triAGENS GmbH, CGN Part of the ArangoDB team c 2013 triAGENS GmbH | 2013-11-6
  3. 3. Table of contents 1 Definition 2 Use Cases 3 Databases 4 Traversals 5 Visualisation c 2013 triAGENS GmbH | 2013-11-6
  4. 4. What is a graph? A set of arbitrary objects, called vertices c 2013 triAGENS GmbH | 2013-11-6
  5. 5. What is a graph? A set of arbitrary objects, called vertices And a set of relations between them, called edges c 2013 triAGENS GmbH | 2013-11-6
  6. 6. Formal Definition Let V be the set of vertices Let E ⊆ V × V be the set of edges Define G = (V , E ) is a graph c 2013 triAGENS GmbH | 2013-11-6
  7. 7. Formal Definition Let V be the set of vertices Let E ⊆ V × V be the set of edges Define G = (V , E ) is a graph Define δ + (n) = v ∈V |(n,v )∈E 1 is the indegree of n ∈ V Define δ − (n) = 1 is the outdegree of n ∈ V Define δ(n) = as the degree of n ∈ V v ∈V |(v ,n)∈E δ + (n) + δ − (n) c 2013 triAGENS GmbH | 2013-11-6
  8. 8. Directed Graphs Edges have a direction One vertex is the source The other vertex is the target Formal: (a, b) ∈ E (b, a) ∈ E And (a, b) ∈ E ∧ (b, a) ∈ E ⇒ (a, b) = (b, a) c d b a c 2013 triAGENS GmbH | 2013-11-6
  9. 9. Example: Navigation Systems c 2013 triAGENS GmbH | 2013-11-6
  10. 10. Undirected Graphs Edges do not have a direction No vertex is source or target Formal: (a, b) ∈ E ⇔ (b, a) ∈ E And (a, b) ∈ E ∧ (b, a) ∈ E ⇒ (a, b) = (b, a) c d b a c 2013 triAGENS GmbH | 2013-11-6
  11. 11. Example: Social Networks Charly Diana Bob Alice c 2013 triAGENS GmbH | 2013-11-6
  12. 12. Property Graphs Vertices have properties in addition to a label Edges have properties in addition to a label c 2013 triAGENS GmbH | 2013-11-6
  13. 13. Graphs in Relational Databases m Edge Vertex n c 2013 triAGENS GmbH | 2013-11-6
  14. 14. Where else to store Graphs? c 2013 triAGENS GmbH | 2013-11-6
  15. 15. How to store Graphs? We will have an example using ArangoDB. First Example: Create new database using Graphs API DEMO TIME c 2013 triAGENS GmbH | 2013-11-6
  16. 16. How to store Graphs? Second Example: You already have vertices. How to add edges? DEMO TIME c 2013 triAGENS GmbH | 2013-11-6
  17. 17. But what can we do with the data now? c 2013 triAGENS GmbH | 2013-11-6
  18. 18. Queries on graphs Mechanism to query a graph Starts at one specific vertex Searches all connected vertices Searches children of these vertices Until predefined boundary is reached Order of vertices can be configured c 2013 triAGENS GmbH | 2013-11-6
  19. 19. The visitor Active at each searched vertex Can execute queries on this vertex like collecting attributes Does know the path followed to reach the current vertex Does not know vertices that will be visited in future c 2013 triAGENS GmbH | 2013-11-6
  20. 20. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 c 2013 triAGENS GmbH | 2013-11-6
  21. 21. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 0 Nuts: 0 c 2013 triAGENS GmbH | 2013-11-6
  22. 22. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 0 Nuts: 0 c 2013 triAGENS GmbH | 2013-11-6
  23. 23. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 0 Nuts: 0 c 2013 triAGENS GmbH | 2013-11-6
  24. 24. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 2 Nuts: 3 c 2013 triAGENS GmbH | 2013-11-6
  25. 25. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 2 Nuts: 3 c 2013 triAGENS GmbH | 2013-11-6
  26. 26. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 2 Nuts: 3 c 2013 triAGENS GmbH | 2013-11-6
  27. 27. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 4 Nuts: 3 c 2013 triAGENS GmbH | 2013-11-6
  28. 28. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 4 Nuts: 3 c 2013 triAGENS GmbH | 2013-11-6
  29. 29. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 4 Nuts: 3 c 2013 triAGENS GmbH | 2013-11-6
  30. 30. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 9 Nuts: 8 c 2013 triAGENS GmbH | 2013-11-6
  31. 31. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 9 Nuts: 8 c 2013 triAGENS GmbH | 2013-11-6
  32. 32. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 9 Nuts: 8 c 2013 triAGENS GmbH | 2013-11-6
  33. 33. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 10 Nuts: 9 c 2013 triAGENS GmbH | 2013-11-6
  34. 34. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 12 Nuts: 10 c 2013 triAGENS GmbH | 2013-11-6
  35. 35. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 12 Nuts: 12 c 2013 triAGENS GmbH | 2013-11-6
  36. 36. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 13 Nuts: 13 c 2013 triAGENS GmbH | 2013-11-6
  37. 37. Traversals Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 13 Nuts: 13 Done c 2013 triAGENS GmbH | 2013-11-6
  38. 38. Traversals Live Example: Execute traversal in ArangoDB DEMO TIME c 2013 triAGENS GmbH | 2013-11-6
  39. 39. Visualisation Example: How to view the graph DEMO TIME c 2013 triAGENS GmbH | 2013-11-6

×