28. GraphAware
TM
Node Record in the Node Store (9 bytes), first bit = inUse flag
Relationship Record in the Relationship Store (33 bytes), first bit = inUse flag, second bit unused
next
relationship
(35 bits)
next
property
(36 bits)
first node
(35 bits)
second node
(35 bits)
type
(16
bits)
first node's
previous
relationship
(35 bits)
first node's
next
relationship
(35 bits)
second
node's first
relationship
(35 bits)
second
node's next
relationship
(35 bits)
next property
(36 bits)
Neo4j Data Layout
29. GraphAware
TM
Neo4j APIs allow developers to
completely ignore relationship direction
when querying the graph.
Traversal APIs
38. ipsum
FRIEND_OF
name: “Michael”
User
name: “Laura”
User
date: 2014-01-29
from: “London”
to: “Nottingham”
Ride
DRIVER
name: “Alice”
User
PASSENGER
date: 2014-01-27
from: “Brighton”
to: “Hastings”
Ride
PASSENGER
name: “Peter”
User
PASSENGER
name: “Jenny”
User
DRIVER
RATED
rating: 5RATED
rating: 3
Qualifying by
Properties
39. GraphAware
TM
START
ride=node({id})
MATCH
(ride)<-‐[r:RATED]-‐(passenger)
WHERE
r.rating
>
3
RETURN
passenger
Who liked the ride? (Cypher)
40. GraphAware
TM
for
(Relationship
r
:
ride.getRelationships(INCOMING,
RATED))
{
if
((int)
r.getProperty("rating")
>
3)
{
Node
passenger
=
r.getStartNode();
//do
something
with
it
}
}
Who liked the ride? (Java)
41. FRIEND_OF
name: “Michael”
User
name: “Laura”
User
date: 2014-01-29
from: “London”
to: “Nottingham”
Ride
DRIVER
name: “Alice”
User
PASSENGER
date: 2014-01-27
from: “Brighton”
to: “Hastings”
Ride
PASSENGER
name: “Peter”
User
PASSENGER
name: “Jenny”
User
DRIVER
LOVED
NEUTRAL
Qualifying by
Relationship Type
42. GraphAware
TM
START
ride=node({id})
MATCH
(ride)<-‐[r:LIKED|LOVED]-‐(passenger)
RETURN
passenger
Who liked the ride? (Cypher)
43. GraphAware
TM
for
(Relationship
r
:
ride.getRelationships(INCOMING,
LIKED,
LOVED))
{
Node
passenger
=
r.getStartNode();
//do
something
with
it
}
Who liked the ride? (Java)
61. GraphAware
TM
Next
meetup
• The
transport
graph
– Roads,
Nodes
and
Automobiles
(Jacqui
Read)
– Transport
Network
Route
Finding
Using
A
Graph
(Ian
Cartwright
&
Ben
Earlham)
• 26th
February
2014
• Here!