/** * @param Digraph $graph * @param int $vertex */ private function depthSearch(Digraph $graph, int $vertex) { $this->marked[$vertex] = true; foreach ($graph->adjacent($vertex) as $item) { if ($this->marked($item)) { continue; } $this->depthSearch($graph, $item); } }