为 public 交通应用程序计算行程的最佳算法是什么?

What are the best algorithms to compute an itinerary for a public transport app?

我正在为 public 运输应用程序创建一个应用程序,我需要计算行程。

但是,我不确定使用什么算法?像 Dijkstra 或 A* 这样的经典寻路算法?

我必须同时处理这两个问题

  1. 基本寻路(停到停不走)
  2. 高级寻路(在站点之间行走)
  3. 更难将两者结合成一个算法

让我不知道究竟应该选择什么。

感谢您的帮助

Mods:如果我的 post 不属于它

,请随意将问题移至适当的位置

Dijkstra 与 A*:

A* 计算速度更快,但可能会给出错误的结果,Dijkstra 会一直找到 shortest/fastest 路径。

我会为该应用程序使用 Dijkstra。

伪代码:

class Path
{
    List<Node> nodesOfThePath;
    int length;
}

List<Path> paths = findAllLinksRelatedTo(startPoint); //You have to write a function to get the nodes linked to the given point
paths.Sort(); //sort using the length, ascending

while (paths.length > 0)
{
    if (paths[0].getLastestNode() == FinalPoint)
        return (paths[0]); //this is the shortest one

    List<Path> tempPaths = findAllLinksRelatedTo(paths[0].getLastestNode()); //get all nodes related to the lastest one of the shortest actual path or null if none was found
    paths.removeAt(0); //remove the shortest path
    foreach (tempPath in tempPaths)
        paths.Add(tempPath);
    paths.sort();
}
return (null); //no path found