Uniqueness of the infinite component in a random graph with applications to percolation and spin glasses