added undirected functionality