/end class graph ///////////////////////////////////////////////////////////////class dfsapp public static void main(string[argsgraph thegraph new graph()thegraph addvertex(' ')/ (start for dfsthegraph addvertex(' ')/ thegraph addvertex(' ')/ thegraph addvertex(' ')/ thegraph addvertex(' ')/ thegraph addedge( )thegraph addedge( )thegraph addedge( )thegraph addedge( )/ab /bc /ad /de system out print("visits")thegraph dfs()/depth-first search system out println()/end main(/end class dfsapp ///////////////////////////////////////////////////////////////breadth-first search as we saw in the depth-first searchthe algorithm acts as though it wants to get as far away from the starting point as quickly as possible in the breadth-first searchon the other handthe algorithm likes to stay as close as possible to the starting point it visits all the vertices adjacent to the starting vertexand only then goes further afield this kind of search is implemented using queue instead of stack an example figure shows the same graph as figure but here the breadth-first search is used againthe numbers indicate the order in which the vertices are visited figure breadth-first search is the starting vertexso you visit it and make it the current vertex then you follow these rules