Skip to content

Instantly share code, notes, and snippets.

@jafstar
Created October 24, 2014 20:18
Show Gist options
  • Save jafstar/3abfd63b9b70ff62c4d7 to your computer and use it in GitHub Desktop.
Save jafstar/3abfd63b9b70ff62c4d7 to your computer and use it in GitHub Desktop.
Cayley Example
http://blog.thefrontiergroup.com.au/2014/10/look-cayley/
// paths that lead to users of the tools
var a = g.V('sass').In('uses')
var b = g.V('sublime text').In('uses')
// Who uses both tools
var c = a.Intersect(b).ToArray()
// What tools are used by all of those people
var software = g.V.apply(this, c).Out('uses').ToArray()
// Convert an array to a hash with counts
var results = {}
_.each(software, function(s){
if(results[s]==null){ results[s]=0; }
results[s] +=1;
})
// Remove search terms
delete results['sass']
delete results['sublime text']
// Emit results
g.Emit({tools: results, users: c})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment