Refactor GraphVisitor.

* Make def_event_handler wherever GraphVisitor is included.
* Extract distance map support into a module.