+ All Categories
Home > Technology > In The Land Of Graphs...

In The Land Of Graphs...

Date post: 10-May-2015
Category:
Upload: fernand-galiana
View: 225 times
Download: 3 times
Share this document with a friend
Description:
Scottland Ruby Conference 2014
Popular Tags:
61
In the land of graphs Fernand Galiana @kitesurfer
Transcript
Page 1: In The Land Of Graphs...

In the land of graphsFernand Galiana

@kitesurfer

Page 2: In The Land Of Graphs...
Page 3: In The Land Of Graphs...
Page 4: In The Land Of Graphs...
Page 5: In The Land Of Graphs...

Agenda• Graph morphology

• Persistence mechanisms

• Terminology

• Modeling

• Graph databases and API’s

• Integrating with Ruby/Rails

• How to win $1,000,000

Page 6: In The Land Of Graphs...

Graph Databases

Page 7: In The Land Of Graphs...

Morphology

Dots and lines

Page 8: In The Land Of Graphs...

Undirected graph (~200BC)

Page 9: In The Land Of Graphs...

Directed graph (~14th-16th century)

Page 10: In The Land Of Graphs...

MultiRelational Graph (19th century)

followsfollows

likes

likes

Page 11: In The Land Of Graphs...

Property Graph (present)

followsfollows

likes

likes

name: Fred age: 29

name: Jim age: 19

Page 12: In The Land Of Graphs...

Property Graph (cont)

followsfollows

likes

likes

name: Fred age: 29

name: James age: 19

weight: 0.9 date: 11/12/13

Page 13: In The Land Of Graphs...

@jimweirich

Page 14: In The Land Of Graphs...

Persistence

Page 15: In The Land Of Graphs...

Any database can model a graph

Page 16: In The Land Of Graphs...

Index Base Traversal

DC

E

A

BB,C E E,D

CB

D E

A

Page 17: In The Land Of Graphs...

DC

E

A

BB,C E E,D

CB

D E

A

Index Base Traversal

Page 18: In The Land Of Graphs...

DC

E

A

BB,C E E,D

CB

D E

A

Index Base Traversal

Page 19: In The Land Of Graphs...

DC

E

A

BB,C E E,D

CB

D E

A

Index Base Traversal

Page 20: In The Land Of Graphs...

A graph database is any storage system that can provide index-free adjacency.

Page 21: In The Land Of Graphs...

GraphDB

DC

E

A

B

Page 22: In The Land Of Graphs...

GraphDB

DC

E

A

B

Page 23: In The Land Of Graphs...

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

Page 24: In The Land Of Graphs...

@jimweirich

Page 25: In The Land Of Graphs...

Why use a graph DB?

• Recommendations - densifying the graph

• Social

• Ranking

• Merging domains

• Data analysis

Page 26: In The Land Of Graphs...

Terminology

Page 27: In The Land Of Graphs...

Terminology

1 2follows

3

likesloves

Page 28: In The Land Of Graphs...

Terminology

1 2follows

3

likesloves

OUT Vertex IN Vertex

Page 29: In The Land Of Graphs...

Terminology

1 2follows

3

likesloves

vertex 1 OUT edges

Page 30: In The Land Of Graphs...

Terminology

1 2follows

3

likesloves

vertex 2 IN edges

Page 31: In The Land Of Graphs...

Terminology

1 2follows

3

likesloves

vertex 3 BOTH edges

Page 32: In The Land Of Graphs...

@jimweirich

Page 33: In The Land Of Graphs...

Modeling

A B

Page 34: In The Land Of Graphs...

Modeling

• Vertex

• Edge

• Properties

• Relationships

Page 35: In The Land Of Graphs...

Modeling

• Assess the space

• Nodes = Entities

• Edges = connections + semantic context

• NProperties = entity attrs + meta

• EProperties = strength + weight

Page 36: In The Land Of Graphs...

@jimweirich

Page 37: In The Land Of Graphs...

The Scene

Page 38: In The Land Of Graphs...

DSLs

• Cypher (Neo4j)

• Gremlin (BluePrint)

• SPARQL

Page 39: In The Land Of Graphs...

Rexster

• Rexster (REST)

• RexPro (bin)

• Rexster Kibbles

Page 40: In The Land Of Graphs...

Blueprints

Page 41: In The Land Of Graphs...

Gremlin

Page 42: In The Land Of Graphs...

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()

• …

Page 43: In The Land Of Graphs...

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')

Page 44: In The Land Of Graphs...

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]

Page 45: In The Land Of Graphs...

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

Page 46: In The Land Of Graphs...

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]

Page 47: In The Land Of Graphs...

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]

Page 48: In The Land Of Graphs...

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]

Page 49: In The Land Of Graphs...

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

Page 50: In The Land Of Graphs...

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

Page 51: In The Land Of Graphs...

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

Page 52: In The Land Of Graphs...

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]

Page 53: In The Land Of Graphs...

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]

Page 54: In The Land Of Graphs...

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]

Page 55: In The Land Of Graphs...

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]

Page 56: In The Land Of Graphs...

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}

Page 57: In The Land Of Graphs...

DEMO!

• Rexster DogHouse

• Wewoo(coz self promotion is underated!)

Page 58: In The Land Of Graphs...

@jimweirich

Page 59: In The Land Of Graphs...

Conclusion

• Mining relationships

• Recommendation, data analysis

• Scoring, Ranking

• Understand problem space

• Search engine integration

• Combining several problem spaces

Page 60: In The Land Of Graphs...

References

• https://github.com/tinkerpop/gremlin

• http://gremlindocs.com

• http://sql2gremlin.com

• github.com/derailed/wewoo

• @jimweirich

Page 61: In The Land Of Graphs...

Is a Graph worth a thousand joins? !

!

!

Thank you! @kitesurfer

[email protected]


Recommended