当前位置: 首页 > news >正文

顺德高端网站设计关键词挖掘长尾词

顺德高端网站设计,关键词挖掘长尾词,动态网站是什么,黄页 推广戴克斯特拉算法(英语:Dijkstras algorithm),又称迪杰斯特拉算法、Dijkstra算法,是由荷兰计算机科学家艾兹赫尔戴克斯特拉在1956年发现的算法。 算法过程: 1.首先设置开始节点的成本值为0,并将…

戴克斯特拉算法(英语:Dijkstra's algorithm),又称迪杰斯特拉算法、Dijkstra算法,是由荷兰计算机科学家艾兹赫尔·戴克斯特拉在1956年发现的算法。

算法过程:

1.首先设置开始节点的成本值为0,并将开始节点放入检测列表中。

2.将检测列表中的所有点按到目标点所需的成本值排序,选择成本最小的节点作为当前节点,并将其移出检测列表。

3.将当前点周围的点中不包含在检测列表中的点加入到检测列表,将周围点加入到已检测列表中。

4.更新检测列表中的节点到当前节点的成本值。

5.重复2,3,4直到找到目标点。

代码实现:

public class Dijkstra : FindPathAlgorithm
{public Dijkstra(int[,] mapData, int xCount, int zCount) : base(mapData, xCount, zCount){}public override List<Vector2Int> FindPath(Vector2Int startPos, Vector2Int goalPos){DataNode dataNode = this.DijkstraFind(startPos, goalPos);if (dataNode == null){Debug.LogError("寻路有误,请检查参数是否正确");return null;}return Utils.GetPath(dataNode);}DataNode DijkstraFind(Vector2Int startPos, Vector2Int goalPos){//存储要检测的点List<DataNode> frontier = new List<DataNode>();//存储已经检测的点List<Vector2Int> reached = new List<Vector2Int>();DataNode startNode = new DataNode(startPos, null);startNode.gCost = 0;frontier.Add(startNode);reached.Add(startPos);while (frontier.Count > 0){DataNode currentNode = GetLowestgCostNode(frontier);frontier.Remove(currentNode);if (currentNode.pos == goalPos){Debug.Log("完成!!!");return new DataNode(goalPos, currentNode.parent);}List<DataNode> neighbors = GetNeighbors(currentNode.pos, reached);foreach (DataNode neighbourNode in neighbors){if (!frontier.Contains(neighbourNode)){neighbourNode.parent = currentNode;frontier.Add(neighbourNode);}reached.Add(neighbourNode.pos);}this.UpdateCost(frontier, currentNode);}return null;}//更新成本值void UpdateCost(List<DataNode> nodes, DataNode currentNode){for (int i = 0; i < nodes.Count; i++){int newCost = currentNode.gCost + CalculateDistanceCost(nodes[i].pos, currentNode.pos);if (nodes[i].gCost > newCost){nodes[i].gCost = newCost;}}}List<DataNode> GetNeighbors(Vector2Int current, List<Vector2Int> reached){List<DataNode> neighbors = new List<DataNode>();for (int i = 0; i < Utils.pointDir.Count; i++){Vector2Int neighbor = current + Utils.pointDir[i];if (this.IsCanAdd(neighbor, reached)){neighbors.Add(new DataNode(neighbor, null));}}return neighbors;}bool IsCanAdd(Vector2Int current, List<Vector2Int> reached){if (reached.Contains(current))return false;if (current.x >= 0 && current.y >= 0 && current.x < MapData.m_MapData.GetLength(1) && current.y < MapData.m_MapData.GetLength(0)){//如果是障碍物,则不能被Addif (MapData.m_MapData[current.y, current.x] == 1){return false;}return true;}return false;}private int CalculateDistanceCost(Vector2Int a, Vector2Int b){return Mathf.Abs(a.x - b.x) + Mathf.Abs(a.y - b.y);}private DataNode GetLowestgCostNode(List<DataNode> pathNodeList){DataNode lowestFCostNode = pathNodeList[0];for (int i = 1; i < pathNodeList.Count; i++){if (pathNodeList[i].gCost < lowestFCostNode.gCost){lowestFCostNode = pathNodeList[i];}}return lowestFCostNode;}
}

结果:

参考链接:

Pathfinding in Unity - Part3: Dijkstra Algorithm Theory (youtube.com)

Pathfinding in Unity - Part4: Dijkstra Algorithm Implementation (youtube.com)

How Dijkstra's Algorithm Works (youtube.com)

戴克斯特拉算法 - 维基百科,自由的百科全书 (wikipedia.org)

http://www.yidumall.com/news/46243.html

相关文章:

  • wordpress自媒体主题破解网站seo重庆
  • 建网站难吗seo免费系统
  • 深圳建材公司app推广优化网站排名
  • iis建立的网站打不开百度推广好不好做
  • 万网搭建淘宝客网站seo网络推广方法
  • 阿里云服务器可以用来干什么上海seo推广方法
  • 北京营销网站制作计算机培训课程
  • 做费网站郑州网络营销顾问
  • 蚌埠网站制作公司费用网站推广的方法
  • 网站开发总结经验和教训seo优化内容
  • 360路由器做网站免费推广的网站平台
  • 小程序abc威海百度seo
  • 乐山网站建设公司全球搜官网
  • 广州 建设 招聘信息网站北京网站外包
  • 字体模板素材免费下载网站关键词优化工具
  • 如何免费注册自己的网站360seo优化
  • 做网站建设分哪些类型企业网站怎么推广
  • 美国做电商网站有哪些自动收录网
  • 网站网站优化哪有培训seo
  • 梅州网站制作baidu合肥做网站的公司有哪些
  • 做网站作业淘宝运营培训班学费大概多少
  • 网站建设进度及实过程googleplay
  • 如何盗用网站模板福州百度首页优化
  • 高端网站建设 企业网站建站网络推广公司是干嘛的
  • 网站英文域名是什么bt最佳磁力搜索引擎吧
  • 单页网站在线制作站长工具 忘忧草
  • 怎么做网站文字优化网络营销策略案例
  • 网站一个人可以做吗怎样在百度上发帖子
  • 深圳做网站比较好的公司有哪些seo排名的方法
  • 口碑好的常州网站优化游戏推广公司靠谱吗