Beispiel #1
0
 /// <summary>
 /// 找到边 从this到toNode节点的边,出边表
 /// </summary>
 /// <param name="fromRN"></param>
 internal void RemoveEdge(RoadEdge re)
 {
     if (re == null)
     {
         throw new ArgumentNullException();
     }
     dicEdge.Remove(RoadEdge.GetHashCode(this, re.rnTo));
 }
Beispiel #2
0
 internal void RemoveEdge(RoadNode toRN)
 {
     if (toRN == null)
     {
         throw new ArgumentNullException();
     }
     dicEdge.Remove(RoadEdge.GetHashCode(this, toRN));
 }
        public void RemoveDirectedEdge(T roadNodeHash, RoadEdge edge)
        {
            RoadNode rn = this.Find(roadNodeHash);

            if (rn != null)
            {
                rn.RemoveEdge(edge.GetHashCode());
            }
        }
Beispiel #4
0
        /// <summary>
        /// 查找方法,新的结构采用出边表
        /// </summary>
        /// <param name="toRoadNode">出节点</param>
        /// <returns></returns>
        internal RoadEdge FindRoadEdge(RoadNode toRoadNode)
        {
            int iHashkey = RoadEdge.GetHashCode(this, toRoadNode);

            if (dicEdge.ContainsKey(iHashkey))
            {
                return(dicEdge[iHashkey]);
            }
            return(null);
        }
Beispiel #5
0
 public void RemoveEdge(RoadNode fromRoadNode, RoadNode ToRoadNode)
 {
     if (fromRoadNode != null && ToRoadNode != null)
     {
         RoadEdge re = new RoadEdge(fromRoadNode, ToRoadNode);
         //邻接矩阵中删除边
         adlistNetWork.RemoveDirectedEdge(fromRoadNode.GetHashCode(), new RoadEdge(fromRoadNode, ToRoadNode));
         //上下文路段字典中删除边
         this.dicRoadEdge.Remove(re.GetHashCode());
     }
 }
Beispiel #6
0
 /// <summary>
 /// 注意在出边表中,保持roadedge的from字段是this节点,否则函数抛出异常
 /// </summary>
 /// <param name="roadEdge"></param>
 internal void AddRoadEdge(RoadEdge roadEdge)
 {
     if (roadEdge != null)
     {
         if (!Contains(roadEdge.GetHashCode()))
         {
             //加入判断是否是当前点的出边的信息防止出错
             if (roadEdge.rnFrom != this)
             {
                 throw new Exception("添加了不属于该顶点的边");
             }
             dicEdge.Add(roadEdge.GetHashCode(), roadEdge);
         }
         else
         {
             throw new ArgumentException("添加了重复的边!");
         }
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Beispiel #7
0
 public void AddRoadEdge(RoadEdge re)
 {
     if (re.rnFrom == null || re.rnTo != null)
     {
         if (this.FindRoadNode(re.rnFrom) != null && this.FindRoadNode(re.rnFrom) != null)
         {
             //将RoadEdge添加到字典
             this.dicRoadEdge.Add(re.GetHashCode(), re);
             //将边添加到添加邻接矩阵网络中
             adlistNetWork.AddDirectedEdge(re.rnFrom.GetHashCode(), re);
         }
         else
         {
             throw new ArgumentException("没有在网络中添加创建道路边的节点");
         }
     }
     else
     {
         throw new ArgumentNullException("无法用空节点添加边");
     }
 }
Beispiel #8
0
 public void AddRoadEdge(RoadNode fromRoadNode, RoadNode ToRoadNode)
 {
     if (fromRoadNode != null && ToRoadNode != null)
     {
         if (this.FindRoadNode(fromRoadNode) != null && this.FindRoadNode(ToRoadNode) != null)
         {
             //创建边
             RoadEdge re = new RoadEdge(fromRoadNode, ToRoadNode);
             //将RoadEdge添加到仿真上下文han字典
             this.dicRoadEdge.Add(re.GetHashCode(), re);
             //将边添加到添加邻接矩阵网络中
             adlistNetWork.AddDirectedEdge(fromRoadNode.GetHashCode(), re);
         }
         else
         {
             throw new ArgumentException("没有在网络中添加创建道路边的节点");
         }
     }
     else
     {
         throw new ArgumentNullException("无法用空节点添加边");
     }
 }