Doctrine\OrientDB\Graph\Algorithm\Dijkstra::calculatePotentials PHP Метод

calculatePotentials() защищенный Метод

Recursively calculates the potentials of the graph, from the starting point you specify with ->setStartingVertex(), traversing the graph due to Vertex's $connections attribute.
protected calculatePotentials ( Doctrine\OrientDB\Graph\VertexInterface $vertex )
$vertex Doctrine\OrientDB\Graph\VertexInterface
    protected function calculatePotentials(VertexInterface $vertex)
    {
        $connections = $vertex->getConnections();
        $sorted = array_flip($connections);
        krsort($sorted);
        foreach ($connections as $id => $distance) {
            $v = $this->getGraph()->getVertex($id);
            $v->setPotential($vertex->getPotential() + $distance, $vertex);
            foreach ($this->getPaths() as $path) {
                $count = count($path);
                if ($path[$count - 1]->getId() === $vertex->getId()) {
                    $this->paths[] = array_merge($path, array($v));
                }
            }
        }
        $vertex->markPassed();
        // Get loop through the current node's nearest connections
        // to calculate their potentials.
        foreach ($sorted as $id) {
            $vertex = $this->getGraph()->getVertex($id);
            if (!$vertex->isPassed()) {
                $this->calculatePotentials($vertex);
            }
        }
    }