public function createGraphsComponents()
    {
        $visitedVertices = array();
        $graphs = array();

        // for each vertices
        foreach ($this->graph->getVertices()->getMap() as $vid => $vertex) {
            // did I visit this vertex before?
            if (!isset($visitedVertices[$vid])) {

                $alg = $this->createSearch($vertex);
                // get all vertices of this component
                $newVertices = $alg->getVertices();

                // mark the vertices of this component as visited
                foreach ($newVertices->getIds() as $vid) {
                    $visitedVertices[$vid] = true;
                }

                $graphs []= $this->graph->createGraphCloneVertices($newVertices);
            }
        }

        return $graphs;
    }
public function createGraphsComponents()
    {
        $visitedVertices = array();
        $graphs = array();

        // for each vertices
        foreach ($this->graph->getVertices()->getMap() as $vid => $vertex) {
            // did I visit this vertex before?
            if (!isset($visitedVertices[$vid])) {

                $alg = $this->createSearch($vertex);
                // get all vertices of this component
                $newVertices = $alg->getVertices();

                // mark the vertices of this component as visited
                foreach ($newVertices->getIds() as $vid) {
                    $visitedVertices[$vid] = true;
                }

                $graphs []= $this->graph->createGraphCloneVertices($newVertices);
            }
        }

        return $graphs;
    }
public function createGraphsComponents ( ) { $ visitedVertices = array ( ) ; $ graphs = array ( ) ; // for each vertices foreach ( $ this -> graph -> getVertices ( ) -> getMap ( ) as $ vid => $ vertex ) { // did I visit this vertex before? if ( ! isset ( $ visitedVertices [ $ vid ] ) ) { $ alg = $ this -> createSearch ( $ vertex ) ; // get all vertices of this component $ newVertices = $ alg -> getVertices ( ) ; // mark the vertices of this component as visited foreach ( $ newVertices -> getIds ( ) as $ vid ) { $ visitedVertices [ $ vid ] = true ; } $ graphs [ ] = $ this -> graph -> createGraphCloneVertices ( $ newVertices ) ; } } return $ graphs ; }
separate input graph into separate independant and unconnected graphs

@return Graph[]
@uses Graph::getVertices()
@uses AlgorithmSearchBreadthFirst::getVertices()
separate input graph into separate independant and unconnected graphs