Inverse Mermin-Wagner theorem for classical spin models on graphs