Bus public transport algorithm

前端 未结 7 1794
耶瑟儿~
耶瑟儿~ 2021-01-30 11:38

I am working on an offline C# application that can find bus routes. I can extract the timetable/bus/route data. I am searching for the most simple solution that will work with

7条回答
  •  长发绾君心
    2021-01-30 12:26

    Try this as your data model.

    Bus 1 goes to stops A, B and C. Bus 2 goes to stops B, D and E.

    I would store a unique node based on both bus and stop, with distances to nodes being based on time. We would have node A1, B1, C1, B2, D2 and E2. In the special case of transfers apply the wait for the next bus as the distance between nodes. For example, if Bus 1 arrives at stop B 30 minutes before Bus 2, travel time from B1 to B2 is 30 minutes.

    You should than be able to apply Dijkstra's Algorithm.

提交回复
热议问题