Analyzer.DuplicateEdgeDetector.CountEdges C# (CSharp) Method

CountEdges() protected method

protected CountEdges ( ) : void
return void
        CountEdges()
        {
            
            if (m_bEdgesCounted)
            {
                return;
            }

            m_iUniqueEdges = 0;
            m_iEdgesWithDuplicates = 0;

            IEdgeCollection oEdges = m_oGraph.Edges;

            Boolean bGraphIsDirected =
                (m_oGraph.Directedness == GraphDirectedness.Directed);

            // Create a dictionary of vertex ID pairs.  The key is the vertex ID
            // pair and the value is true if the edge has duplicates or false if it
            // doesn't.

            Dictionary<Int64, Boolean> oVertexIDPairs =
                new Dictionary<Int64, Boolean>(oEdges.Count);

            foreach (IEdge oEdge in oEdges)
            {
                Int64 i64VertexIDPair = EdgeUtil.GetVertexIDPair(oEdge);
                Boolean bEdgeHasDuplicate;

                if (oVertexIDPairs.TryGetValue(i64VertexIDPair,
                    out bEdgeHasDuplicate))
                {
                    if (!bEdgeHasDuplicate)
                    {
                        // This is the edge's first duplicate.

                        m_iUniqueEdges--;
                        m_iEdgesWithDuplicates++;

                        oVertexIDPairs[i64VertexIDPair] = true;
                    }

                    m_iEdgesWithDuplicates++;
                }
                else
                {
                    m_iUniqueEdges++;

                    oVertexIDPairs.Add(i64VertexIDPair, false);
                }
            }

            m_iTotalEdgesAfterMergingDuplicatesNoSelfLoops = 0;

            foreach (Int64 i64VertexIDPair in oVertexIDPairs.Keys)
            {
                Int32 iVertexID1 = (Int32)(i64VertexIDPair >> 32);
                Int32 iVertexID2 = (Int32)i64VertexIDPair;

                if (iVertexID1 != iVertexID2)
                {
                    m_iTotalEdgesAfterMergingDuplicatesNoSelfLoops++;
                }
            }

            m_bEdgesCounted = true;

        }