当前位置: 首页>>代码示例>>C#>>正文


C# EdgeType.GetEdge方法代码示例

本文整理汇总了C#中EdgeType.GetEdge方法的典型用法代码示例。如果您正苦于以下问题:C# EdgeType.GetEdge方法的具体用法?C# EdgeType.GetEdge怎么用?C# EdgeType.GetEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EdgeType的用法示例。


在下文中一共展示了EdgeType.GetEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEdges

 /// <summary>
 /// Enumerates edges connected wih this vertex type
 /// </summary>
 /// <param name="etype">A type of edge type to look for</param>
 /// <param name="dir">Direction of edge</param>
 /// <returns></returns>
 public IEnumerable<IEdge> GetEdges(EdgeType etype, Direction dir)
 {
   BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>> map;
   switch (dir)
   {
     case Direction.Out:
       if (m_tailToHeadEdges.TryGetValue(etype, out map))
         foreach (var p1 in map)
           foreach (var p2 in p1.Value)
           {
             Vertex vertex1 = GetVertex(p2.Key);
             foreach (UInt64 l in p2.Value)
             {
               VertexId vId = (int)l;
               Vertex vertex2 = p1.Key.GetVertex(vId);
               EdgeId eId = (int)(l >> 32);
               Edge edge = etype.GetEdge(eId, vertex1, vertex2);
               yield return edge;
             }
           }
       break;
     case Direction.In:
       if (m_headToTailEdges.TryGetValue(etype, out map))
         foreach (var p1 in map)
           foreach (var p2 in p1.Value)
           {
             Vertex vertex1 = GetVertex(p2.Key);
             foreach (UInt64 l in p2.Value)
             {
               VertexId vId = (int)l;
               Vertex vertex2 = p1.Key.GetVertex(vId);
               EdgeId eId = (int)(l >> 32);
               Edge edge = etype.GetEdge(eId, vertex2, vertex1);
               yield return edge;
             }
           }
       break;
     case Direction.Both:
       if (m_tailToHeadEdges.TryGetValue(etype, out map))
         foreach (var p1 in map)
           foreach (var p2 in p1.Value)
           {
             Vertex vertex1 = GetVertex(p2.Key);
             foreach (UInt64 l in p2.Value)
             {
               VertexId vId = (int)l;
               Vertex vertex2 = p1.Key.GetVertex(vId);
               EdgeId eId = (int)(l >> 32);
               Edge edge = etype.GetEdge(eId, vertex1, vertex2);
               yield return edge;
             }
           };
       if (m_headToTailEdges.TryGetValue(etype, out map))
         foreach (var p1 in map)
           foreach (var p2 in p1.Value)
           {
             Vertex vertex1 = GetVertex(p2.Key);
             foreach (UInt64 l in p2.Value)
             {
               VertexId vId = (int)l;
               Vertex vertex2 = p1.Key.GetVertex(vId);
               EdgeId eId = (int)(l >> 32);
               Edge edge = etype.GetEdge(eId, vertex2, vertex1);
               yield return edge;
             }
           }
       break;
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:75,代码来源:VertexType.cs

示例2: Traverse

    /// <summary>
    /// Selects all neighbor Vertices from or to this vertex and for the given edge type.
    /// </summary>
    /// <param name="vertex1">the start Vertex</param>
    /// <param name="etype">the type of edges to follow</param>
    /// <param name="dir">Direction.</param>
    /// <returns>Dictionary of vertex key with edge path(s) to vertex</returns>
    internal Dictionary<Vertex, HashSet<Edge>> Traverse(Vertex vertex1, EdgeType etype, Direction dir)
    {
      Dictionary<Vertex, HashSet<Edge>> result = new Dictionary<Vertex, HashSet<Edge>>(10);
      if (etype.Directed)
      {
        if (etype.Unrestricted)
        {
          foreach (var pair in etype.m_unrestrictedEdges)
          {
            UnrestrictedEdge edgeStruct = pair.Value;
            bool headSameVertex = vertex1.VertexType == edgeStruct.m_headVertexType && vertex1.VertexId == edgeStruct.m_headVertexId;
            bool tailSameVertex = vertex1.VertexType == edgeStruct.m_tailVertexType && vertex1.VertexId == edgeStruct.m_tailVertexId;
            Vertex other;
            if (headSameVertex)
            {
              VertexType vt = edgeStruct.m_tailVertexType;
              other = vt.GetVertex(edgeStruct.m_tailVertexId);
            }
            else
            {
              if (tailSameVertex == false)
                continue;
              VertexType vt = edgeStruct.m_headVertexType;
              other = vt.GetVertex(edgeStruct.m_headVertexId);
            }
#if EdgeDebug
          Edge edge = etype.GetEdge(graph, pair.Key, other, vertex1);
#else
            Edge edge = new Edge(MyGraph, etype, pair.Key, vertex1, other);
#endif
            AddToResult(result, other, edge);
          }
        }
        else
          foreach (var pair in etype.m_restrictedEdges)
          {
            UInt64 vertexVertex = pair.Value;
            VertexId headVertexId = (VertexId) (vertexVertex >> 32);
            VertexId tailVertexId = (Int32) (UInt32)vertexVertex;
            bool headSameVertex = vertex1.VertexType == etype.HeadType && vertex1.VertexId == headVertexId;
            bool tailSameVertex = vertex1.VertexType == etype.TailType && vertex1.VertexId == tailVertexId;
            Vertex other;
            if (headSameVertex)
            {
              VertexType vt = etype.TailType;
              other = vt.GetVertex(tailVertexId);
            }
            else
            {
              if (tailSameVertex == false)
                continue;
              VertexType vt = etype.HeadType;
              other = vt.GetVertex(headVertexId);
            }
#if EdgeDebug
          Edge edge = etype.GetEdge(g, pair.Key, other, vertex1);
#else
            Edge edge = new Edge(MyGraph, etype, pair.Key, vertex1, other);
#endif
            AddToResult(result, other, edge);
          }
      }
      else
      {
        BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>> map;
        BTreeSet<EdgeIdVertexId> set;
        switch (dir)
        {
          case Direction.Out:
            if (m_tailToHeadEdges.TryGetValue(etype, out map))
            {
              foreach (KeyValuePair<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>> pair in map)
              {
                BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>> innerMap = pair.Value;
                if (innerMap.TryGetValue(vertex1.VertexId, out set))
                {
                  foreach (EdgeIdVertexId id in set)
                  {
                    Vertex vertex2 = new Vertex(MyGraph, pair.Key, (VertexId)id);
                    EdgeId eId = (EdgeId)(id >> 32);
                    Edge edge = etype.GetEdge(eId, vertex1, vertex2);
                    AddToResult(result, vertex2, edge);
                  }
                }
              }
            }
            break;
          case Direction.In:
            if (m_headToTailEdges.TryGetValue(etype, out map))
            {
              foreach (KeyValuePair<VertexType, BTreeMap<EdgeId, BTreeSet<EdgeIdVertexId>>> pair in map)
              {
                BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>> innerMap = pair.Value;
//.........这里部分代码省略.........
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:101,代码来源:VertexType.cs


注:本文中的EdgeType.GetEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。