methods akin to the depth-first search (dfsand breadth-first search (bfsalgorithms defined previously for undirected graphs (sections and such explorations can be usedfor exampleto answer reachability questions the directed depth-first search and breadth-first search methods we develop in this section for performing such explorations are very similar to their undirected counterparts in factthe only real difference is that the directed depth-first search and breadth-first search methods only traverse edges according to their respective directions the directed version of dfs starting at vertex can be described by the recursive algorithm in code fragment (see figure code fragment the directed dfs algorithm figure an example of dfs in digraph(aintermediate stepwherefor the first timean already visited vertex (dfwis reached(bthe completed dfs the tree edges are shown with solid blue linesthe back edges are shown with dashed blue linesand the forward and cross edges are shown with dashed black lines the order in which the vertices are visited is indicated by label next to each vertex the edge (ord,dfwis back edgebut (dfw,ordis forward edge edge (bos,sfois forward edgeand (sfo,laxis cross edge