self arc=arc if arc is noneself cost= elseself cost initial cost+arc cost def end(self)"""returns the node at the end of the path""if self arc is nonereturn self initial elsereturn self arc to_node def nodes(self)"""enumerates the nodes for the path this starts at the end and enumerates nodes in the path backwards ""current self while current arc is not noneyield current arc to_node current current initial yield current initial def initial_nodes(self)"""enumerates the nodes for the path before the end node this starts at the end and enumerates nodes in the path backwards ""if self arc is not noneyield from self initial nodes( def __repr__(self)"""returns string representation of path""if self arc is nonereturn str(self initialelif self arc actionreturn (str(self initial)+"\ --"+str(self arc action+"--"+str(self arc to_node)elsereturn str(self initial)+--"+str(self arc to_nodeexample search problems the first search problem is one with nodes where the least-cost path is one with many arcs see figure note that this example is used for the unit testsso the test (in searchgenericwill need to be changed if this is changed searchproblem py -(continued problem search_problem_from_explicit_graph{' ',' ',' ',' ',' '}[arc(' ',' ', )arc(' ',' ', )arc(' ',' ', )arc(' ',' ', )version june