为公共交通应用计算路线的最佳算法是什么?

时间:2018-09-15 08:50:12

标签: algorithm directions

我正在为公共交通应用创建一个应用,因此我需要计算行程。

但是,我不确定要使用哪种算法?经典的寻路算法,例如Dijkstra或A *?

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

  1. 基本寻路(无需走动即可停下来停下来)
  2. 高级寻路(在站点之间行走)
  3. 更难将两者组合成一个算法

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

感谢您的帮助

Mods:如果我的帖子不属于该问题,请随意将问题移至适当位置

1 个答案:

答案 0 :(得分:1)

Dijkstra vs A *:

A *计算速度较快,但会给出错误的结果,Dijkstra始终会找到最短/最快的路径。

我将在该应用程序中使用Dijkstra。

伪代码:

E/flutter ( 7708): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 7708): Connection closed while receiving data
E/flutter ( 7708): #0      IOClient.send.<anonymous closure> (package:http/src/io_client.dart:52:15)
E/flutter ( 7708): #1      _invokeErrorHandler (dart:async/async_error.dart:13:29)
E/flutter ( 7708): #2      _HandleErrorStream._handleError (dart:async/stream_pipe.dart:286:9)
E/flutter ( 7708): #3      _ForwardingStreamSubscription._handleError (dart:async/stream_pipe.dart:168:13)
E/flutter ( 7708): #4      _RootZone.runBinaryGuarded (dart:async/zone.dart:1326:10)
E/flutter ( 7708): #5      _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:355:15)
E/flutter ( 7708): #6      _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:373:16)
E/flutter ( 7708): #7      _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:272:7)
E/flutter ( 7708): #8      _ForwardingStreamSubscription._addError (dart:async/stream_pipe.dart:137:11)
E/flutter ( 7708): #9      _addErrorWithReplacement (dart:async/stream_pipe.dart:188:8)
E/flutter ( 7708): #10     _HandleErrorStream._handleError (dart:async/stream_pipe.dart:291:11)
E/flutter ( 7708): #11     _ForwardingStreamSubscription._handleError (dart:async/stream_pipe.dart:168:13)
E/flutter ( 7708): #12     _RootZone.runBinaryGuarded (dart:async/zone.dart:1326:10)
E/flutter ( 7708): #13     _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:355:15)
E/flutter ( 7708): #14     _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:373:16)
E/flutter ( 7708): #15     _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:272:7)
E/flutter ( 7708): #16     _SyncStreamController._sendError (dart:async/stream_controller.dart:767:19)
E/flutter ( 7708): #17     _StreamController._addError (dart:async/stream_controller.dart:647:7)
E/flutter ( 7708): #18     _StreamController.addError (dart:async/stream_controller.dart:599:5)
E/flutter ( 7708): #19     _HttpParser._onDone (dart:_http/http_parser.dart:822:25)
E/flutter ( 7708): #20     _RootZone.runGuarded (dart:async/zone.dart:1302:10)
E/flutter ( 7708): #21     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
E/flutter ( 7708): #22     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
E/flutter ( 7708): #23     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
E/flutter ( 7708): #24     _SyncStreamController._sendDone (dart:async/stream_controller.dart:771:19)
E/flutter ( 7708): #25     _StreamController._closeUnchecked (dart:async/stream_controller.dart:628:7)
E/flutter ( 7708): #26     _StreamController.close (dart:async/stream_controller.dart:621:5)
E/flutter ( 7708): #27     _Socket._onData (dart:io/runtime/binsocket_patch.dart:1721:21)
E/flutter ( 7708): #28     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
E/flutter ( 7708): #29     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter ( 7708): #30     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
E/flutter ( 7708): #31     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
E/flutter ( 7708): #32     _StreamController._add (dart:async/stream_controller.dart:639:7)
E/flutter ( 7708): #33     _StreamController.add (dart:async/stream_controller.dart:585:5)
E/flutter ( 7708): #34     new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1283:35)
E/flutter ( 7708): #35     _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:812:18)
E/flutter ( 7708): #36     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 7708): #37     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)