CountIncidentEdge
        (
            IEdge oIntergroupEdge,
            Int32 iGroup1Index,
            Int32 iGroup2Index,
            IList <IntergroupEdgeInfo> oIntergroupEdges,
            Dictionary <Int32, IntergroupEdgeInfo> oIntergroupEdgeIndexes
        )
        {
            Debug.Assert(oIntergroupEdge != null);
            Debug.Assert(iGroup1Index >= 0);
            Debug.Assert(iGroup2Index >= 0);
            Debug.Assert(oIntergroupEdges != null);
            Debug.Assert(oIntergroupEdgeIndexes != null);
            AssertValid();

            Double dPositiveEdgeWeight = EdgeUtil.GetPositiveEdgeWeight(
                oIntergroupEdge);

            // Does an object already exist for the iGroup1Index/iGroup2Index pair?

            IntergroupEdgeInfo oIntergroupEdgeInfo;

            if (oIntergroupEdgeIndexes.TryGetValue(iGroup2Index,
                                                   out oIntergroupEdgeInfo))
            {
                // Yes.

                oIntergroupEdgeInfo.Edges++;
                oIntergroupEdgeInfo.EdgeWeightSum += dPositiveEdgeWeight;
            }
            else
            {
                // No.  Create one.

                oIntergroupEdgeInfo = new IntergroupEdgeInfo(
                    iGroup1Index, iGroup2Index, 1, dPositiveEdgeWeight);

                oIntergroupEdges.Add(oIntergroupEdgeInfo);
                oIntergroupEdgeIndexes.Add(iGroup2Index, oIntergroupEdgeInfo);
            }
        }
        InitializeMetadata
        (
            IGraph oGraph,
            ICollection <IVertex> oVerticesToLayOut
        )
        {
            Debug.Assert(oGraph != null);
            Debug.Assert(oVerticesToLayOut != null);
            AssertValid();

            foreach (IVertex oVertex in oVerticesToLayOut)
            {
                // Create an object that will store all calculated values for the
                // vertex.

                FruchtermanReingoldVertexInfo oFruchtermanReingoldVertexInfo =
                    new FruchtermanReingoldVertexInfo(oVertex.Location);

                // The object could be stored in a metadata key, but because the
                // number of retrievals can be very large, it's more efficient to
                // store it in the Tag.  If a Tag already exists, save it in a
                // metadata key.

                SaveTag(oVertex);
                oVertex.Tag = oFruchtermanReingoldVertexInfo;
            }

            foreach (IEdge oEdge in oGraph.Edges)
            {
                // Do the same for edges.  In this case, each edge has just one
                // piece of information, the edge weight.

                SaveTag(oEdge);

                oEdge.Tag = (Single)EdgeUtil.GetPositiveEdgeWeight(oEdge);
            }
        }