Created
July 20, 2011 16:20
-
-
Save pdlug/1095280 to your computer and use it in GitHub Desktop.
Pacer loop test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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