如何找到从a[x][y]到任意a[v][w]的最短路径?
How can i find the shortest path form a[x][y] to any a[v][w]?
我有这样的东西
————
aaa——
,
————
b————
如何在最短的步长内到达b的所有a ?我怎么用图来表示呢?
一个*算法可能很适合你。这种变化是寻找游戏开发中最短(成本最低)路径的常见解决方案。对于图表示,定义一个称为Node和Connection的结构。你可以使用std::vector来存储顶点,std::vector来存储连接(边)。
typedef struct
{
std::string name;
//Other data that You need.
}Node;
typedef struct
{
Node* nodeA;
Node* nodeB;
int travelCost;
//other data that may come in handy
}Connection;
std::vector<Node> nodes;
std::vector<Connection> nodeConnections;
相关文章:
- 内存效率表示最短路径的方法?
- 用于查找网格中最短路径的算法
- 查找最短路径算法
- BFS 打印最短路径
- 使用 Dijkstra 算法跟踪两个节点之间的最短路径
- 使用C++具有两个数字的最短路径算法.(C++)
- 使用迭代深度优先搜索算法的未加权图的最短路径
- 如何仅在 2 个节点之间获取最短路径,给定邻接列表有向图?
- 如何使用贝尔曼-福特算法返回所有具有捆绑重量的最短路径?
- 使用优先级队列查找所有与 Dijkstra 相同的最短路径
- 尝试在图形中查找最短路径时的无限循环
- C++计算有向图中的最短路径
- 使用BFS存储和打印最短路径
- 如何制作由原始图形的最短路径边组成的新图形
- 有没有一种方法可以使用弗洛伊德-沃歇尔算法给出最短路径,其中存在负权重循环而不允许重叠边缘?
- 加权图的开始和结束的最短路径
- 使 c++11 Dijkstra 实现返回最短路径
- 弗洛伊德最短路径算法C++
- Dijkstra 最短路径算法性能 std::p riority_queue VS std::set.
- 在 stl 中使用向量和对的最有效实现 Dijkstra 最短路径C++