You can write these type of algorithms easily with a graph-programming language like Gremlin (<a href="https://github.com/tinkerpop/gremlin/wiki" rel="nofollow">https://github.com/tinkerpop/gremlin/wiki</a>):<p><pre><code> g = new Neo4jGraph('/tmp/neo4j')
// calculate basic collaborative filtering for vertex 1
m = [:]
g.v(1).out('likes').in('likes').out('likes').groupCount(m)
m.sort{a,b -> a.value <=> b.value}
// calculate the primary eigenvector (eigenvector centrality) of a graph
m = [:]; c = 0;
g.V.out.groupCount(m).loop(2){c++ < 1000}
m.sort{a,b -> a.value <=> b.value}
</code></pre>
When a user signs in with Facebook or Twitter, you can load their friends and followers into a graph database such as Neo4j and then use Gremlin to run these type of social-graph algorithms.<p>Graph DBs are fast in general because there is no external index lookup during traversals (the index containing adjacent nodes are located within the node). Pair that with local-rank (<a href="http://markorodriguez.com/2011/03/30/global-vs-local-graph-ranking/" rel="nofollow">http://markorodriguez.com/2011/03/30/global-vs-local-graph-r...</a>), and you can do real-time ranking and analysis.