public function __construct(Graph $graph, $startVertex) { $this->graph = $graph; $this->startVertex = $startVertex; $verticesCount = $graph->getVerticesCount(); $this->marked = array_fill(0, $verticesCount, false); $this->edgeTo = array_fill(0, $verticesCount, null); $this->dfs($startVertex); }