fixed directed/undirected bug