Visitor Pattern and traversal mechanism

Viewed 2466

I have a graph and a set of very simple visitors that do some calculations on vertices/edges of the graph such as getting the total weight of edges and pretty-printing the graph.

I would like to go one step further and have visitors that visit the graph in DFS fashion for example.

However, I think the visitor pattern should be separate from the traversal mechanism, and the traversal method should be created using other pattern such as iterator. Am I correct or do I miss something?

1 Answers
Related