Added support for undirected graphs