add useful classes and functions for BFS