Add handling for algorithm specification and implement BFS