Analyzer.Community.InitializeDeltaQs C# (CSharp) Method

InitializeDeltaQs() public method

public InitializeDeltaQs ( LinkedList communities, Int32 edgesInGraph ) : void
communities LinkedList
edgesInGraph System.Int32
return void
        public void InitializeDeltaQs
            ( LinkedList<Community> communities, Int32 edgesInGraph)
        {
            Debug.Assert(communities != null);
            Debug.Assert(edgesInGraph > 0);

            Single fMaximumDeltaQ = Single.MinValue;
            m_oCommunityPairWithMaximumDeltaQ = null;

            // These calculations are based on equation 8 of "Finding Community
            // Structure in Very Large Networks," by Clauset, Newman and Moore.

            Debug.Assert(m_oVertices.Count == 1);

            Int32 iKi = m_iDegree;
            Single f2M = 2F * edgesInGraph;
            Single fOneOver2M = 1F / f2M;
            Single fOneOver2MSquared = 1F / (f2M * f2M);

            foreach (CommunityPair oCommunityPair in m_oCommunityPairs.Values)
            {
                Community oCommunity2 = oCommunityPair.Community2;

                Debug.Assert(oCommunity2.Vertices.Count == 1);

                Int32 iKj = oCommunity2.Degree;

                Single fDeltaQ =
                    fOneOver2M - ((Single)(iKi * iKj) * fOneOver2MSquared);

                oCommunityPair.DeltaQ = fDeltaQ;

                if (fDeltaQ > fMaximumDeltaQ)
                {
                    fMaximumDeltaQ = fDeltaQ;
                    m_oCommunityPairWithMaximumDeltaQ = oCommunityPair;
                }
            }
        }