Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created May 13, 2011 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjurney/970078 to your computer and use it in GitHub Desktop.
Save rjurney/970078 to your computer and use it in GitHub Desktop.
Playing with Pacer
#!`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]}" } }
@pangloss
Copy link

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

@rjurney
Copy link
Author

rjurney commented May 14, 2011

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