<commit_before><?php

namespace Fhaculty\Graph\Algorithm;

use Fhaculty\Graph\Graph;

class Complete extends Base
{
    /**
     *
     * @var Graph
     */
    private $graph;

    public function __construct(Graph $graph)
    {
        $this->graph = $graph;
    }

    /**
     * checks whether this graph is complete (every vertex has an edge to any other vertex)
     *
     * @return boolean
     * @uses Graph::getVertices()
     * @uses Vertex::hasEdgeTo()
     */
    public function isComplete()
    {
        // copy of array (separate iterator but same vertices)
        $c = $vertices = $this->graph->getVertices();
        // from each vertex
        foreach ($vertices as $vertex) {
            // to each vertex
            foreach ($c as $other) {
                // missing edge => fail
                if ($other !== $vertex && !$vertex->hasEdgeTo($other)) {
                    return false;
                }
            }
        }

        return true;
    }
}
<commit_msg>Improve documentation<commit_after><?php

namespace Fhaculty\Graph\Algorithm;

use Fhaculty\Graph\Graph;

/**
 * Basic algorithms for working with complete graphs
 *
 * A complete graph is a graph in which every pair of vertices is connected
 * by an edge.
 *
 * @link http://en.wikipedia.org/wiki/Complete_graph
 * @link http://mathworld.wolfram.com/CompleteGraph.html
 */
class Complete extends Base
{
    /**
     * Graph to operate on
     *
     * @var Graph
     */
    private $graph;

    /**
     * instantiate new complete algorithm
     *
     * @param Graph $graph
     */
    public function __construct(Graph $graph)
    {
        $this->graph = $graph;
    }

    /**
     * checks whether this graph is complete (every vertex has an edge to any other vertex)
     *
     * @return boolean
     * @uses Graph::getVertices()
     * @uses Vertex::hasEdgeTo()
     */
    public function isComplete()
    {
        // copy of array (separate iterator but same vertices)
        $c = $vertices = $this->graph->getVertices();
        // from each vertex
        foreach ($vertices as $vertex) {
            // to each vertex
            foreach ($c as $other) {
                // missing edge => fail
                if ($other !== $vertex && !$vertex->hasEdgeTo($other)) {
                    return false;
                }
            }
        }

        return true;
    }
}

{'fraction_non_alphanumeric': 0.11478843736908254, 'fraction_numerical': 0.0, 'mean_word_length': 1.7511520737327189, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5784561', 'n_tokens_mistral': 675, 'n_tokens_neox': 660, 'n_words': 198}