예제 #1
0
    NodeXLEdgeToGleeEdge
    (
        IEdge oEdge
    )
    {
        Debug.Assert(oEdge != null);
        AssertValid();

        Object oValue = oEdge.GetRequiredValue(
            ReservedMetadataKeys.SugiyamaGleeEdge,
            typeof(Microsoft.Glee.Edge)
            );

        return ( (Microsoft.Glee.Edge)oValue );
    }
예제 #2
0
파일: EdgeUtil.cs 프로젝트: yesbb12/NetMap
        GetEdgeWeight
        (
            IVertex vertex1,
            IVertex vertex2
        )
        {
            Debug.Assert(vertex1 != null);
            Debug.Assert(vertex2 != null);

            Double dEdgeWeight = 0;

            // Get the edges that connect the two vertices.  This includes all
            // connecting edges and does not take directedness into account.

            ICollection <IEdge> oConnectingEdges =
                vertex1.GetConnectingEdges(vertex2);

            Int32 iConnectingEdges = oConnectingEdges.Count;
            IEdge oConnectingEdgeWithEdgeWeight = null;

            switch (vertex1.ParentGraph.Directedness)
            {
            case GraphDirectedness.Directed:

                // There can be 0, 1, or 2 edges between the vertices.  Only
                // one of them can originate at vertex1.

                Debug.Assert(iConnectingEdges <= 2);

                foreach (IEdge oConnectingEdge in oConnectingEdges)
                {
                    if (oConnectingEdge.BackVertex == vertex1)
                    {
                        oConnectingEdgeWithEdgeWeight = oConnectingEdge;
                        break;
                    }
                }

                break;

            case GraphDirectedness.Undirected:

                // There can be 0 or 1 edges between the vertices.  There can't
                // be 2 edges, because the duplicate edges (A,B) and (B,A) have
                // been merged.

                Debug.Assert(iConnectingEdges <= 1);

                if (iConnectingEdges == 1)
                {
                    oConnectingEdgeWithEdgeWeight = oConnectingEdges.First();
                }

                break;

            default:

                Debug.Assert(false);
                break;
            }

            if (oConnectingEdgeWithEdgeWeight != null)
            {
                dEdgeWeight = (Double)
                              oConnectingEdgeWithEdgeWeight.GetRequiredValue(
                    ReservedMetadataKeys.EdgeWeight, typeof(Double));
            }

            return(dEdgeWeight);
        }