Refactor iterators for graph.