Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'model' # from the example/imdb neo4j.rb example
- class Actor
- def acted_in_cool_movies
- traverse.outgoing(:acted_in).find_all {|movie| movie.relationship?(:cool_movies, :incoming)}
- end
- end
- cool_movies = Node.new
- all_cool_movies = [m1,m2] # m1,m2 are two movies - defined somewhere else
- all_cool_movies.each {|movie| cool_movies.relationships.outgoing(:cool_movies) << movie}
- cool_movies.traverse.outgoing(:cool_movies).incoming(:acted_in).depth(2).filter{ respond_to?(:acted_in_cool_movies) and acted_in_cool_movies.size == all_cool_movies.size}.each {|n| puts n}
- # Simple solution but inefficient solution
- m1.actors.to_a & m2.actors.to_a
Add Comment
Please, Sign In to add comment