done the contents of the stack is the route you took from the starting vertex to get where you are as you move away from the starting vertexyou push vertices as you go as you move back toward the starting vertexyou pop them the order in which you visit the vertices is abfhcdgie you might say that the depth-first search algorithm likes to get as far away from the starting point as quickly as possibleand returns only when it reaches dead end if you use the term depth to mean the distance from starting pointyou can see where the name depth-first search comes from an analogy an analogy you might think about in relation to depth-first search is maze the maze-perhaps one of the people-size ones made of hedgespopular in england--consists of narrow passages (think of edgesand intersections where passages meet (verticessuppose that someone is lost in the maze she knows there' an exit and plans to traverse the maze systematically to find it fortunatelyshe has ball of string and marker pen she starts at some intersection and goes down randomly chosen passageunreeling the string at the next intersectionshe goes down another randomly chosen passageand so onuntil finally she reaches dead end at the dead end she retraces her pathreeling in the stringuntil she reaches the previous intersection here she marks the path she' been down so she won' take it againand tries another path when she' marked all the paths leading from that intersectionshe returns to the previous intersection and repeats the process the string represents the stackit "remembersthe path taken to reach certain point the graphn workshop applet and dfs you can try out the depth-first search with the dfs button in the graphn workshop applet (the is for not directednot weighted start the applet at the beginningthere are no vertices or edgesjust an empty rectangle you create vertices by double-clicking the desired location the first vertex is automatically labeled athe second one is band so on they're colored randomly to make an edgedrag from one vertex to another figure shows the graph of figure as it looks when created using the applet