Skip to content

Instantly share code, notes, and snippets.

@tjackiw
Created December 19, 2012 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjackiw/4335269 to your computer and use it in GitHub Desktop.
Save tjackiw/4335269 to your computer and use it in GitHub Desktop.
Using a Graph Database with Ruby. Part II: Integration
require 'rubygems'
require 'bundler/setup'
require 'neo4j'
Neo4j::Transaction.run do
me = Neo4j::Node.new(:name => 'Me', :age => 31)
bob = Neo4j::Node.new(:name => 'Bob', :age => 29)
mark = Neo4j::Node.new(:name => 'Mark', :age => 34)
mary = Neo4j::Node.new(:name => 'Mary', :age => 32)
john = Neo4j::Node.new(:name => 'John', :age => 33)
andy = Neo4j::Node.new(:name => 'Andy', :age => 31)
me.both(:friends) << bob
bob.both(:friends) << mark
mark.both(:friends) << mary
mary.both(:friends) << john
john.both(:friends) << andy
puts me.outgoing(:friends).depth(5).map{|node| node[:name]}.join(" => ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment