split to directed and undirected graphs