Can someone help me to think of a better way to adapt Dijkstra's Algorithm in these conditions? All I thought of so far wasn't good.
Example of input:
GP4578 MADRID 01:00 PORTO 02:00
IK6587 PORTO 03:00 VALENCIA 05:00 05:30 TENERIFE 08:00
AB5874 VALENCIA 05:40 BERLIM 10:00
"VALENCIA 05:00 05:30" This is a stopover, all of them are about 30min. The flight has arrival and departure time, flight number, the origin and destination city.
So, I need get the shortest path from a city to another, ok, no problem. I can't find how to structure this, I've been trying since last week. Can someone give me ideas? Which are my vertex's, each city or each flight? How to use the edges? How to do the stopovers?
答案 0 :(得分:0)
基本上,您可以使用每个城市/机场作为节点并将航班作为其间的连接进行建模。然后是连接/飞行的重量。如果您假设所有中途停留都是30分钟(在简化模型中),那么您可以为每个访问节点添加额外费用(在这种情况下为30分钟)
查看此维基百科页面(https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)上的图片。现在查看这张包含繁忙机场http://www.worldmapsatlas.com/world-map/thematic/world-air-routes-map.html航班的地图,了解如何建立模型。