Пример #1
0
        public Dictionary <IDependencyGroup, ZoneFitResult> GetZoneFitResults()
        {
            ZoneFitResult[] results = new ZoneFitResult[this.AllGroups.Count];
            var             options = new ParallelOptions {
                MaxDegreeOfParallelism = Network.MAX_DEGREE_OF_PARALLELISM
            };

            //Parallel.ForEach(this.AllGroups, options, group =>
            foreach (IDependencyGroup group in this.AllGroups)
            {
                ZoneFitResult mcc = this.GetBestZoneFit(group);
                lock (zoneFitLock)
                {
                    results[group.Id - 1] = mcc;
                }
            }//);

            Dictionary <IDependencyGroup, ZoneFitResult> fitResults = new Dictionary <IDependencyGroup, ZoneFitResult>();

            for (int i = 0; i < results.Length; i++)
            {
                fitResults.Add(this.AllGroups[i], results[i]);
            }

            return(fitResults);
        }
Пример #2
0
        public ZoneFitResult GetBestZoneFit(IDependencyGroup zone) //MCC
        {
            ZoneFitResult FIT = new ZoneFitResult(zone);

            foreach (KeyValuePair <int, List <int> > pair in this.Communities.AllCommunities)
            {
                int TP = 0;
                foreach (int id in pair.Value)
                {
                    if (zone.AllVertices.Contains(this.Network.Vertices[id]))
                    {
                        TP += 1;
                    }
                }
                ////Puvodni clanek
                //double FN = zone.AllVertices.Count - TP;
                //double FP = pair.Value.Count - TP;
                double FN = zone.AllVertices.Count - TP;
                double FP = pair.Value.Count - TP;
                double TN = this.Network.Vertices.Count - FP - FN - TP;

                double num   = TP * TN - FP * FN;
                double denom = (TP + FP) * (TP + FN) * (TN + FP) * (TN + FN);

                double fit = num / Math.Sqrt(denom);
                if (fit > FIT.Value)
                {
                    FIT.Value          = fit;
                    FIT.CommunityId    = pair.Key;
                    FIT.CommunityCount = pair.Value.Count;
                    FIT.OverlapCount   = TP;
                }

                if (FIT.Value == 1)
                {
                    return(FIT);
                }
            }

            return(FIT);
        }