Factorization of product graphs for partitioning and domain decomposition