both sequential and OpenMP versions for up and down BFS