public function getVertices()
    {
        $visited = array();
        $todo = array($this->vertex);
        while ($vertex = array_shift($todo)) {
            if (!isset($visited[$vertex->getId()])) {
                $visited[$vertex->getId()] = $vertex;

                foreach (array_reverse($this->getVerticesAdjacent($vertex)->getMap(), true) as $vid => $nextVertex) {
                    $todo[] = $nextVertex;
                }
            }
        }

        return new Vertices($visited);
    }
public function getVertices()
    {
        $visited = array();
        $todo = array($this->vertex);
        while ($vertex = array_shift($todo)) {
            if (!isset($visited[$vertex->getId()])) {
                $visited[$vertex->getId()] = $vertex;

                foreach (array_reverse($this->getVerticesAdjacent($vertex)->getMap(), true) as $vid => $nextVertex) {
                    $todo[] = $nextVertex;
                }
            }
        }

        return new Vertices($visited);
    }
public function getVertices ( ) { $ visited = array ( ) ; $ todo = array ( $ this -> vertex ) ; while ( $ vertex = array_shift ( $ todo ) ) { if ( ! isset ( $ visited [ $ vertex -> getId ( ) ] ) ) { $ visited [ $ vertex -> getId ( ) ] = $ vertex ; foreach ( array_reverse ( $ this -> getVerticesAdjacent ( $ vertex ) -> getMap ( ) , true ) as $ vid => $ nextVertex ) { $ todo [ ] = $ nextVertex ; } } } return new Vertices ( $ visited ) ; }
calculates an iterative depth-first search

@return Vertices
calculates an iterative depth - first search