Relationship between phase transitions and topological changes in one-dimensional models