Improve graph implementation.
Re-implement graph.setDirected() function.