Implemented the simple ER algorithm for undirected graphs.