예제 #1
0
 public RoadNode FindRoadNode(RoadNode roadNode)
 {
     if (roadNode == null)
     {
         throw new ArgumentNullException("参数不能为Null");
     }
     if (adlistNetWork.Contains(roadNode.GetHashCode()))
     {
         return(adlistNetWork.Find(roadNode.GetHashCode()));
     }
     return(null);
 }
예제 #2
0
        //#region ITrafficEntity 成员
        //public EntityType EntityType
        //{
        //    get
        //    {
        //        return this._entityType;
        //    }
        //    set
        //    {
        //        this._entityType = value;
        //    }
        //}



        //public EntityStatus EntityStatus
        //{
        //    get
        //    {
        //        throw new System.NotImplementedException();
        //    }
        //    set
        //    {
        //        throw new System.NotImplementedException();
        //    }
        //}

        //public MyPoint Postion
        //{
        //    get
        //    {
        //        return this._netWorkPosition;
        //    }
        //    set
        //    {
        //        this._netWorkPosition = value;
        //    }
        //}

        //#endregion

        #region INetWork 成员
        public void AddRoadNode(RoadNode value)
        {
            if (value != null)
            {
                adlistNetWork.AddRoadNode(value.GetHashCode(), value);
            }
        }
예제 #3
0
 public void RemoveRoadNode(RoadNode value)
 {
     if (value != null)
     {
         adlistNetWork.RemoveRoadNode(value.GetHashCode());
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
예제 #4
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());
     }
 }
예제 #5
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("无法用空节点添加边");
     }
 }
예제 #6
0
 /// <summary>
 /// 静态的哈希函数,用来计算某条边的哈希值
 /// </summary>
 public static int GetHashCode(RoadNode rnFrom, RoadNode rnTo)
 {
     return(string.Concat(rnFrom.GetHashCode().ToString(), rnTo.GetHashCode().ToString()).GetHashCode());
 }
예제 #7
0
 /// <summary>
 /// 根据起始节点和结束节点计算边的哈希值
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(string.Concat(rnFrom.GetHashCode().ToString(), rnTo.GetHashCode().ToString()).GetHashCode());
 }