searching for solutions self display( ,"expanding:",path,"cost:",path costself num_expanded + if self problem is_goal(path end())self best_path path self bound path cost self display( ,"new best path:",path,cost:",path costelseneighs self problem neighbors(path end()self display( ,"neighbors are"neighsfor arc in reversed(list(neighs))self add_to_frontier(path(patharc)self display( ,"number of paths expanded:",self num_expanded"(optimalif self best_path else "(no""solution found)"self solution self best_path return self best_path note that this code used reversed in order to expand the neighbors of node in the left-to-right order one might expect it does this because pop(removes the rightmost element of the list the call to list is there because reversed only works on lists and tuplesbut the neighbours can be generated here is unit test and some queriessearchbranchandbound py -(continued from searchgeneric import test if __name__ ="__main__"test(df_branch_and_bound example queriesimport searchproblem searcherb df_branch_and_bound(searchproblem acyclic_delivery_problemprint(searcherb search()find optimal path searcherb df_branch_and_bound(searchproblem cyclic_delivery_problembound= print(searcherb search()find optimal path exercise implement branch-and-bound search uses recursion hintyou don' need an explicit frontierbut can do recursive call for the children exercise after the branch-and-bound search found solutionsam ran search againand noticed different count sam hypothesized that this count was related to the number of nodes that an asearch would use (either expand or be added to the frontieror maybesam thoughtthe count for number of nodes when the bound is slightly above the optimal path case is related to how awould work is there relationship between these countsare there different things that it could count so they are relatedtry to find the most specific statement that is trueand explain why it is true to test the hypothesissam wrote the following codebut isn' sure it is helpfulsearchtest py -code that may be useful to compare aand branch-and-bound version june