Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.