Graph-based Generalization Bounds for Learning Binary Relations