Algo cosine similarity error

It's always better to think about ways to optimise your graph, as to re-use already done calculatios, but, have you tried runnig your query in parallel ?

Do take a look here, it's an interesting discussion: How best to do parallel processing