Skip to content

Instantly share code, notes, and snippets.

@pdlug
Created July 20, 2011 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pdlug/1095280 to your computer and use it in GitHub Desktop.
Save pdlug/1095280 to your computer and use it in GitHub Desktop.
Pacer loop test
require 'bundler/setup'
require 'pacer'
require 'pacer-neo4j'
#graph = Pacer.tg
graph = Pacer.neo4j('/tmp/test-neo4j')
c1 = graph.create_vertex(name: 'Concept 1')
c2 = graph.create_vertex(name: 'Concept 2')
c2a = graph.create_vertex(name: 'Concept 2a')
graph.create_edge(nil, c2, c2a, :same_as)
c2b = graph.create_vertex(name: 'Concept 2b')
graph.create_edge(nil, c2a, c2b, :same_as)
c2c = graph.create_vertex(name: 'Concept 2c')
graph.create_edge(nil, c2b, c2c, :same_as)
c3 = graph.create_vertex(name: 'Concept 3')
c2.out_e(:same_as).in_v.loop { |v|
v.out_e(:same_as).in_v
}.while do |node,depth|
puts (' ' * depth) + node[:name]
:loop
end.to_a
[c1, c2, c3].each do |cr|
puts cr[:name]
unless cr.out_e(:same_as).empty?
cr.out_e(:same_as).in_v.loop { |v|
v.out_e(:same_as).in_v
}.while do |node,depth|
puts (' ' * depth) + node[:name]
# accessing this blows up under neo4j
p node.both_e
:loop
end.to_a
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment