compute cosine sim between grapth a and b