/** * Constructs the adjacency matrix for the MST. * * @param array $edges vertices and edge weights of MST */ function constructMST($edges) { foreach ($edges as $edge) { $this->cluster_heap->insert($edge); $vertex1 = $edge->getStartVertex(); $vertex2 = $edge->getEndVertex(); $this->adjMatrix[$vertex1->getLabel()][$vertex2->getLabel()] = $vertex2->getLabel(); $this->adjMatrix[$vertex2->getLabel()][$vertex1->getLabel()] = $vertex1->getLabel(); if (empty($this->vertices) || !in_array($vertex1, $this->vertices)) { $this->vertices[$vertex1->getLabel()] = $vertex1; } if (empty($this->vertices) || !in_array($vertex2, $this->vertices)) { $this->vertices[$vertex2->getLabel()] = $vertex2; } } }