Created
October 24, 2014 20:18
-
-
Save jafstar/3abfd63b9b70ff62c4d7 to your computer and use it in GitHub Desktop.
Cayley Example
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
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