Added greedy bfs algorithm implementation

Also code refactoring