a bit more strictness and optimisation in GraphUtil.cat