//执行参数计算 void Calculate() { //距离参数 if ((intChoice & intDistance) == intDistance) { disStrategy = new DistanceStrategy(curNetwork.Number); disStrategy.Calculate(curNetwork); tabMain.TabPages.Add(tabDistance); LoadDistanceResult(disStrategy); } //中心度参数 if ((intChoice & intCenter) == intCenter) { coeStrategy = new CoefficientStrategy(curNetwork.Number); coeStrategy.Calculate(curNetwork); tabMain.TabPages.Add(tabCenter); LoadCenterResult(coeStrategy); } //PageRank if ((intChoice & intPageRank) == intPageRank) { prStrategy = new PageRankStrategy(curNetwork.Number); prStrategy.Calculate(curNetwork, 30); tabMain.TabPages.Add(tabPageRank); LoadPageRankResult(prStrategy); } //K-Shell if ((intChoice & intKshell) == intKshell) { kshellStrategy = new KShellStrategy(curNetwork.Number); kshellStrategy.Calculate(curNetwork); tabMain.TabPages.Add(tabKshell); LoadKshellResult(kshellStrategy); } }
//计算接近中心度 void CalClose(pNet curNetwork) { int[,] intDistance; int intCount, intSum; DistanceStrategy disStrategy = new DistanceStrategy(curNetwork.Number); disStrategy.Calculate(curNetwork); intDistance = disStrategy.Distance; foreach(pNode sourNode in curNetwork.Network) { intSum = 0; intCount = 0; foreach(pNode tarNode in curNetwork.Network) { if (intDistance[sourNode.Number,tarNode.Number] > 0) { intCount += 1; intSum += intDistance[sourNode.Number, tarNode.Number]; } } if (intSum == 0) { dubClose[sourNode.Number] = 0; } else { dubClose[sourNode.Number] = intCount * 1.0d / intSum; } } }
//读取距离参数计算结果 void LoadDistanceResult(DistanceStrategy disStrategy) { DensityBox.Text = Convert.ToSingle(disStrategy.AveDistance).ToString(); DiameterBox.Text = disStrategy.Diameter.ToString(); }