getGraph()->createGraphCloneEdges($this->getEdges()); } /** * get all edges on minimum spanning tree * * @return Edges */ abstract public function getEdges(); /** * return reference to current Graph * * @return Graph */ abstract protected function getGraph(); /** * get total weight of minimum spanning tree * * @return float */ public function getWeight() { return $this->getEdges()->getSumCallback(function (Edge $edge) { return $edge->getWeight(); }); } /** * helper method to add a set of Edges to the given set of sorted edges * * @param Edges $edges * @param SplPriorityQueue $sortedEdges */ protected function addEdgesSorted(Edges $edges, SplPriorityQueue $sortedEdges) { // For all edges foreach ($edges as $edge) { assert($edge instanceof Edge); // ignore loops (a->a) if (!$edge->isLoop()) { // Add edges with negative weight because of order in stl $sortedEdges->insert($edge, -$edge->getWeight()); } } } }