public function isSingle()
    {
        try {
            $vertex = $this->graph->getVertices()->getVertexFirst();
        }
        catch (UnderflowException $e) {
            // no first vertex => empty graph => has zero components
            return false;
        }
        $alg = $this->createSearch($vertex);

        return (count($this->graph->getVertices()) === count($alg->getVertices()));
    }
public function isSingle()
    {
        try {
            $vertex = $this->graph->getVertices()->getVertexFirst();
        }
        catch (UnderflowException $e) {
            // no first vertex => empty graph => has zero components
            return false;
        }
        $alg = $this->createSearch($vertex);

        return (count($this->graph->getVertices()) === count($alg->getVertices()));
    }
public function isSingle ( ) { try { $ vertex = $ this -> graph -> getVertices ( ) -> getVertexFirst ( ) ; } catch ( UnderflowException $ e ) { // no first vertex => empty graph => has zero components return false ; } $ alg = $ this -> createSearch ( $ vertex ) ; return ( count ( $ this -> graph -> getVertices ( ) ) === count ( $ alg -> getVertices ( ) ) ) ; }
check whether this graph consists of only a single component

If a Graph consists of only a single component, it is said to be a
connected Graph, otherwise it's called a disconnected Graph.

This method returns exactly the same result as checking
<pre>($this->getNumberOfComponents() === 1)</pre>. However, using this
method is faster than calling getNumberOfComponents(), as it only has to
count all vertices in one component to see if the graph consists of only
a single component.

As such, a null Graph (a Graph with no vertices) is not considered
connected here.

@return boolean
@see self::getNumberOfComponents()
check whether this graph consists of only a single component