Preserving symmetry for undirected graphs