all pairs dcor implementation