Algorithmic Building Blocks For Relationship Analysis Over Large Graphs