matrix concatenate, snap connected components