graphs the current vertex is added to the visited set visited add(current if the current vertex is the goal vertexthen we discontinue the search reporting that we found the goal if current =goalreturn true or return path to goal perhaps otherwisefor every adjacent vertexvto the current vertex in the graphv is pushed on the stack of vertices yet to search unless is already in the visited set in which case the edge leading to is ignored for in adjacent(current, )if not in visitedstack push( if we get this farthen we did not find the goal return false or return an empty path if the while loop in sect terminates the stack was empty and therefore no path to the goal exists this algorithm implements depth first search of graph it can also be implemented recursively if pushing on the stack is replaced with recursive call to depth first search when implemented recursivelythe depth first search function is passed the current vertex and mutable visited set and it returns either the path to the goal or alternatively boolean value indicating that the goal or target was found given the graph in fig the search returned true the iterative version of depth first search can be modified to do breadth first search of graph if the stack is replaced with queue breadth first search is an exhaustive searchmeaning that it looks at all paths at the same timebut will also find the shortest pathwith the least number of edgesbetween any two vertices in graph performing breadth first search on large graphs may take too long to be of practical use kruskal' algorithm consider for moment county which is responsible for plowing roads in the winter but is running out of money due to an unexpected amount of snow the county supervisor has been told to reduce costs by plowing only the necessary roads for the rest of the winter the supervisor wants to find the shortest number of total miles that must be plowed so any person can travel from one point to any other point in the countybut not necessarily by the shortest route the county supervisor wants to minimize the miles of plowed roadswhile guaranteeing you can still get anywhere you need to in the county joseph kruskal was an american computer scientist and mathematician who lived from to he imagined this problemformalized it in terms of weighted graphand devised an algorithm to solve this problem his algorithm was first published in the proceedings of the american mathematical society [ and is commonly called kruskal' algorithm this copy belongs to 'acha