Changed constructor to accept UndirectedGraph instead of interface Graph.