Analyzer.FanMotifDetector.SetFanMotifArcScale C# (CSharp) Method

SetFanMotifArcScale() protected method

protected SetFanMotifArcScale ( ICollection oFanMotifs ) : void
oFanMotifs ICollection
return void
        protected void SetFanMotifArcScale(ICollection<Motif> oFanMotifs)
        {
            Debug.Assert(oFanMotifs != null);

            // The ArcScale property is the FanMotif's leaf count scaled between 0
            // and 1.0, based on the minimum and maximum leaf counts among all
            // FanMotifs.

            Int32 iMinimumLeafCount = 0;
            Int32 iMaximumLeafCount = 0;

            if (oFanMotifs.Count > 0)
            {
                iMinimumLeafCount = oFanMotifs.Min(
                    oMotif => ((FanMotif)oMotif).LeafVertices.Length);

                iMaximumLeafCount = oFanMotifs.Max(
                    oMotif => ((FanMotif)oMotif).LeafVertices.Length);
            }

            foreach (FanMotif oFanMotif in oFanMotifs)
            {
                Single fArcScale;

                if (iMinimumLeafCount == iMaximumLeafCount)
                {
                    // All the leaf counts are the same.  Arbitrarily set the
                    // ArcScale property to the center of the range.

                    fArcScale = 0.5F;
                }
                else
                {
                    fArcScale = MathUtil.TransformValueToRange(
                        oFanMotif.LeafVertices.Length,
                        iMinimumLeafCount, iMaximumLeafCount,
                        0F, 1.0F
                        );
                }

                oFanMotif.ArcScale = fArcScale;
            }


        }