Add support for undirected graphs to Graph class.