コード例 #1
0
 public ZoneFitResult(IDependencyGroup group)
 {
     if (group == null)
     {
         this.Group = null;
     }
     else
     {
         this.Group = group;
     }
 }
コード例 #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);
        }