viewArray = $viewArray; $this->clusterCount = $this->viewArray["cn"]; $this->peerCount = $this->viewArray["pn"]; $this->viewId = $viewId; $this->createClusterList(); $this->calcPeerClusterRatio(); } private function createClusterList() { $clusterArray = $this->viewArray["clusters"]; $this->clusterList = array(); foreach ($clusterArray as $key => $value) { $cluster = new Cluster($value, $key); array_push($this->clusterList, $cluster); } } private function clusterListToHTML() { $result = ""; foreach ($this->clusterList as $value) { $result .= ""; } return $result . "
"; $result .= $value->toHTML(); $result .= "
"; } private function calcPeerClusterRatio() { $this->peerClusterRatioRef = round($this->peerCount / $this->clusterCount,5); $variance = 0.0; $medianArray = array(); foreach ($this->clusterList as $value) { $value->calcPeerClusterRatioNorm($this->peerClusterRatioRef); $variance += pow($value->clusterSize - $this->peerClusterRatioRef, 2); array_push($medianArray, $value->clusterSize); } $variance /= $this->peerCount; $this->peerClusterRatioNormVar = round($variance,5); $this->peerClusterRatioNormStDev = round(sqrt($variance),5); asort($medianArray); $medianArraySize = count($medianArray); $medianMidIndex = round(($medianArraySize - 1) / 2,0,PHP_ROUND_HALF_DOWN); if ($medianArraySize % 2 == 0) { $this->peerClusterRatioNormMed = ($medianArray[$medianMidIndex] + $medianArray[$medianMidIndex + 1]) / 2; } else { $this->peerClusterRatioNormMed = $medianArray[$medianMidIndex]; } } public function toHTML() { $table = ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= "
ViewId:$this->viewId
ClusterCount:$this->clusterCountPeerCount:$this->peerCount
PeerClusterRatioRef:$this->peerClusterRatioRef PeerClusterRatioNormVar:$this->peerClusterRatioNormVarPeerClusterRatioNormStDev:$this->peerClusterRatioNormStDevPeerClusterRatioNormMed:$this->peerClusterRatioNormMed
ClusterListe: "; $table .= $this->clusterListToHTML(); $table .= "
"; return $table; } } ?>