Ejemplo n.º 1
0
        TestGetAdjacentVertex()
        {
            IVertex oVertex1 = m_aoVertices[0];
            IVertex oVertex2 = m_aoVertices[1];

            IEdge oEdge = CreateEdge(oVertex1, oVertex2, true);

            Assert.AreEqual(oVertex2, oEdge.GetAdjacentVertex(oVertex1));
            Assert.AreEqual(oVertex1, oEdge.GetAdjacentVertex(oVertex2));
        }
Ejemplo n.º 2
0
        IncidentEdgeShouldBeHidden
        (
            IEdge oIncidentEdge,
            IVertex oVertex,
            Int32 iGroupIndex,
            Dictionary <Int32, Int32> oGroupIndexDictionary
        )
        {
            Debug.Assert(oIncidentEdge != null);
            Debug.Assert(oVertex != null);
            Debug.Assert(iGroupIndex >= 0);
            Debug.Assert(oGroupIndexDictionary != null);

            Int32 iOtherGroupIndex = oGroupIndexDictionary[
                oIncidentEdge.GetAdjacentVertex(oVertex).ID];

            return(

                // The edge's vertices are not in the same group.

                iOtherGroupIndex != iGroupIndex
                &&

                // The edge has not already been hidden.

                !oIncidentEdge.ContainsKey(ReservedMetadataKeys.SavedVisibility)
                );
        }
Ejemplo n.º 3
0
        TestGetAdjacentVertexBad()
        {
            // Vertex not in edge.

            try
            {
                IVertex oVertex1 = m_aoVertices[0];
                IVertex oVertex2 = m_aoVertices[1];

                IEdge oEdge = CreateEdge(oVertex1, oVertex2, true);

                oEdge.GetAdjacentVertex(m_aoVertices[2]);
            }
            catch (ArgumentException oArgumentException)
            {
                Assert.AreEqual(

                    "Smrf.NodeXL.Core."
                    + "Edge.GetAdjacentVertex: The specified vertex is not one of"
                    + " the edge's vertices.\r\n"
                    + "Parameter name: vertex"
                    ,
                    oArgumentException.Message
                    );

                throw oArgumentException;
            }
        }
    IncidentEdgeShouldBeHidden
    (
        IEdge oIncidentEdge,
        IVertex oVertex,
        Int32 iGroupIndex,
        Dictionary<Int32, Int32> oGroupIndexDictionary
    )
    {
        Debug.Assert(oIncidentEdge != null);
        Debug.Assert(oVertex != null);
        Debug.Assert(iGroupIndex >= 0);
        Debug.Assert(oGroupIndexDictionary != null);

        Int32 iOtherGroupIndex = oGroupIndexDictionary[
            oIncidentEdge.GetAdjacentVertex(oVertex).ID];

        return (

            // The edge's vertices are not in the same group.

            iOtherGroupIndex != iGroupIndex
            &&

            // The edge has not already been hidden.

            !oIncidentEdge.ContainsKey(ReservedMetadataKeys.SavedVisibility)
            );
    }
    IncidentEdgeShouldBeCounted
    (
        IEdge oIncidentEdge,
        IVertex oVertexInGroup1,
        Int32 iGroup1Index,
        Dictionary<Int32, Int32> oGroupIndexDictionary,
        Boolean bUseDirectedness,
        Boolean bGraphIsDirected,
        out Int32 iGroup2Index
    )
    {
        Debug.Assert(oIncidentEdge != null);
        Debug.Assert(oVertexInGroup1 != null);
        Debug.Assert(iGroup1Index >= 0);
        Debug.Assert(oGroupIndexDictionary != null);
        AssertValid();

        IVertex oVertex2 = oIncidentEdge.GetAdjacentVertex(oVertexInGroup1);

        if ( !oGroupIndexDictionary.TryGetValue(
            oVertex2.ID, out iGroup2Index) )
        {
            // The edge's second vertex is not in a group.

            return (false);
        }

        Boolean bEdgesFirstVertexIsVertexInGroup1 =
            (oIncidentEdge.Vertex1 == oVertexInGroup1);

        if (iGroup1Index == iGroup2Index)
        {
            // The edge's vertices are in the same group.  Count the edge only
            // if its first vertex is oVertexInGroup1.  That way, when the same
            // edge is passed to this method again as an incident edge of the
            // edge's second vertex, it won't be counted again.

            return (bEdgesFirstVertexIsVertexInGroup1);
        }
        else if (!bUseDirectedness || !bGraphIsDirected)
        {
            // All edges between group 1 and group 2 should be counted in a
            // single IntergroupEdgeInfo object.  Count the edge only if its
            // second vertex is in a group whose index is greater than or equal
            // to the group index of its first vertex.  (The equal case handles
            // edges whose vertices are within the same group, including
            // self-loops.)  That way, when the same edge is passed to this
            // method again as an incident edge of the edge's second vertex, it
            // won't be counted again.

            return (iGroup2Index >= iGroup1Index);
        }
        else
        {
            // Edges from group 1 to group 2 should be returned in one object,
            // and edges from group 2 to group 1 should be returned in another
            // IntergroupEdgeInfo object.  Count the edge only if its first
            // vertex is in group 1.  That way, when the same edge is passed to
            // this method again as an incident edge of the edge's second
            // vertex, it won't be counted again.

            return (bEdgesFirstVertexIsVertexInGroup1);
        }
    }
        IncidentEdgeShouldBeCounted
        (
            IEdge oIncidentEdge,
            IVertex oVertexInGroup1,
            Int32 iGroup1Index,
            Dictionary <Int32, Int32> oGroupIndexDictionary,
            Boolean bUseDirectedness,
            Boolean bGraphIsDirected,
            out Int32 iGroup2Index
        )
        {
            Debug.Assert(oIncidentEdge != null);
            Debug.Assert(oVertexInGroup1 != null);
            Debug.Assert(iGroup1Index >= 0);
            Debug.Assert(oGroupIndexDictionary != null);
            AssertValid();

            IVertex oVertex2 = oIncidentEdge.GetAdjacentVertex(oVertexInGroup1);

            if (!oGroupIndexDictionary.TryGetValue(
                    oVertex2.ID, out iGroup2Index))
            {
                // The edge's second vertex is not in a group.

                return(false);
            }

            Boolean bEdgesFirstVertexIsVertexInGroup1 =
                (oIncidentEdge.Vertex1 == oVertexInGroup1);

            if (iGroup1Index == iGroup2Index)
            {
                // The edge's vertices are in the same group.  Count the edge only
                // if its first vertex is oVertexInGroup1.  That way, when the same
                // edge is passed to this method again as an incident edge of the
                // edge's second vertex, it won't be counted again.

                return(bEdgesFirstVertexIsVertexInGroup1);
            }
            else if (!bUseDirectedness || !bGraphIsDirected)
            {
                // All edges between group 1 and group 2 should be counted in a
                // single IntergroupEdgeInfo object.  Count the edge only if its
                // second vertex is in a group whose index is greater than or equal
                // to the group index of its first vertex.  (The equal case handles
                // edges whose vertices are within the same group, including
                // self-loops.)  That way, when the same edge is passed to this
                // method again as an incident edge of the edge's second vertex, it
                // won't be counted again.

                return(iGroup2Index >= iGroup1Index);
            }
            else
            {
                // Edges from group 1 to group 2 should be returned in one object,
                // and edges from group 2 to group 1 should be returned in another
                // IntergroupEdgeInfo object.  Count the edge only if its first
                // vertex is in group 1.  That way, when the same edge is passed to
                // this method again as an incident edge of the edge's second
                // vertex, it won't be counted again.

                return(bEdgesFirstVertexIsVertexInGroup1);
            }
        }