Fixed two bugs for undirected graphs.