Tag Archives: degrees of separation

Gremlin with Neography

Gremlin is a domain specific language for traversing property graphs. Neo4j is one of the databases that can speak the gremlin language, and as promised I’ll show you how you can use it to implement friend recommendations as well as degrees of separation.

We can send any gremlin script to Neo4j via the REST API and neography using the execute_script command. Let’s implement suggestions_for so it sends a gremlin script to the server:

def suggestions_for(node)
  node_id = node["self"].split('/').last.to_i
                         filter{it != g.v(node_id)}.
                         name", {:node_id => node_id})

puts "Johnathan should become friends with #{suggestions_for(johnathan).join(', ')}"

# Johnathan should become friends with Mary, Phil

Continue reading

Tagged , , , ,