public function isBipartit()
    {
        // graph has to contain exactly 2 groups
        if ($this->getNumberOfGroups() !== 2) {
            return false;
        }

        // for each vertex
        foreach ($this->graph->getVertices() as $vertex) {
            // get current group
            $group = $vertex->getGroup();
            // for every neighbor vertex
            foreach ($vertex->getVerticesEdge() as $vertexNeighbor) {
                // vertex group must be other group
                if ($vertexNeighbor->getGroup() === $group) {
                    return false;
                }
            }
        }

        return true;
    }
public function isBipartit()
    {
        // graph has to contain exactly 2 groups
        if ($this->getNumberOfGroups() !== 2) {
            return false;
        }

        // for each vertex
        foreach ($this->graph->getVertices() as $vertex) {
            // get current group
            $group = $vertex->getGroup();
            // for every neighbor vertex
            foreach ($vertex->getVerticesEdge() as $vertexNeighbor) {
                // vertex group must be other group
                if ($vertexNeighbor->getGroup() === $group) {
                    return false;
                }
            }
        }

        return true;
    }
public function isBipartit ( ) { // graph has to contain exactly 2 groups if ( $ this -> getNumberOfGroups ( ) !== 2 ) { return false ; } // for each vertex foreach ( $ this -> graph -> getVertices ( ) as $ vertex ) { // get current group $ group = $ vertex -> getGroup ( ) ; // for every neighbor vertex foreach ( $ vertex -> getVerticesEdge ( ) as $ vertexNeighbor ) { // vertex group must be other group if ( $ vertexNeighbor -> getGroup ( ) === $ group ) { return false ; } } } return true ; }
checks whether the input graph's vertex groups are a valid bipartition

@return boolean
@see AlgorithmBipartit() if you do NOT want to take vertex groups into consideration
@uses AlgorithmGroups::getNumberOfGroups()
@uses Vertex::getGroup()
checks whether the input graph s vertex groups are a valid bipartition