Created
May 13, 2011 06:23
-
-
Save rjurney/970078 to your computer and use it in GitHub Desktop.
Playing with Pacer
This file contains 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
#!`which jruby` | |
require 'rubygems' | |
require 'pacer' | |
graph = Pacer.tg | |
graph.import("/tmp/enron_summary.xml") | |
# Focus on one email address, that of Tim Belden | |
sender = graph.v.filter(:address => 'louise.kitchen@enron.com') | |
# Check the vertex's properties | |
sender.inspect | |
# Look into the volume of emails Tim sent to each address | |
out_edges = sender.out_e | |
out_edges.each {|e| vs = e.in_v; vs.each {|v| puts "#{v[:address]} = #{e[:volume]}" } } | |
Undefined method back= for #<V[1234]>
Line 129 in route.rb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
instead of graph.v.filter(:address => ...), just use graph.v(:address => ...) because that way it will use indices if possible and be considerably faster.
You could change the last line to the following:
out_edges.as(:var_name).in_v.each_context { |v| puts "#{ v[:address]} = #{ v.vars[:var_name][:volume] }" }
To get the first result from any route, just use route.first. If you wanted to get the fifth element, you can use route[4].first