Graph databases come with enhanced connectivity of data and whiteboard friendly paradigm. It requires learning a new Graph Traversal Language, that crawls the network and brings informations. It's indeed a fresh new look at how we store web of data and search for it. We'll meet gremlin, from Apache TinkerPop, which provides an abstract layer that make it easy to express your business logic without fighting with the code, and several Open Source graph databases, available for testing and toying.
8. The Vertices
g represents the graph or the gremlin
v()represents all the vertices
g.V(1) is one of the vertice
Vertices always have an id
g.V(1) => v(1)
1
10. Vertice discovery
Use valueMap to discover the graph
Except id and label
g.V(2).valueMap() => {name=wp_die, leaf=tru
g.V(2).valueMap('name') => {name=wp_die}
wp_die
11. The Edges
g.E() represents all the edges
g.E(1) is the edge with id 1
Edges have id, properties
also : start, end and label
CALLS
26. Up to now
nodes and vertices : basic blocs
in and out (and both) : navigation
except(), retain(), in(‘label’) : filtering
Loops with repeat()
Starting at the vertices
43. Applied to properties
Non standard functions
g.V().filter{
it.get().value('name') !=
it.get().value('name').toLowerCase()
}
.count() => 73
44. Closures
Steps often offer possibility for closure
Closure is between {} , uses ‘it.get()’ as current
node, is written in Groovy
Closure should be replaces by step, unless there
is a need for a special manipulation