Calculate transitive of given relation