code styling: add comments and fix pep8
This commit is contained in:
15
graph.py
15
graph.py
@@ -41,19 +41,23 @@ def calc_time(
|
||||
return distance / TransportMethod.WALK.value.speed
|
||||
elif distance <= 10 + 1:
|
||||
speed = 1 / TransportMethod.WALK.value.speed
|
||||
return speed + ((distance - 1) / TransportMethod.CITY.value.speed)
|
||||
new_dist = (distance - 1)
|
||||
speed += (new_dist / TransportMethod.CITY.value.speed)
|
||||
return speed
|
||||
elif distance < 2000 + 10 + 1:
|
||||
speed = 1 / TransportMethod.WALK.value.speed
|
||||
speed += 10 / TransportMethod.CITY.value.speed
|
||||
return speed + ((distance - 1 - 10) / TransportMethod.AUTOBAHN.value.speed)
|
||||
new_dist = (distance - 1 - 10)
|
||||
speed += (new_dist / TransportMethod.AUTOBAHN.value.speed)
|
||||
return speed
|
||||
case TransportKind.TRAIN:
|
||||
if distance <= 25:
|
||||
return distance / TransportMethod.OEPNV.value.speed
|
||||
else:
|
||||
return (distance / TransportMethod.ICE.value.speed)
|
||||
case TransportKind.FLYING:
|
||||
assert(flights != None)
|
||||
assert(frm != None)
|
||||
assert(flights)
|
||||
assert(frm)
|
||||
stops = flights[frm]["stops"]
|
||||
domestic = flights[frm]["domestic"]
|
||||
if domestic:
|
||||
@@ -100,9 +104,10 @@ def create_graph(dataset: DataSet) -> dict:
|
||||
|
||||
# Train
|
||||
is_haltestelle = locations[start].type == LocationType.HALTESTELLE
|
||||
is_airport = locations[start].type == LocationType.FLUGHAFEN
|
||||
is_same_continent = locations[start].is_same_continent(locations[dest])
|
||||
# trains only drive from haltestelle and same continent
|
||||
if is_haltestelle and is_same_continent:
|
||||
if (is_haltestelle or is_airport) and is_same_continent:
|
||||
dest_type = locations[dest].type
|
||||
# there are only trains between haltestellen or airports
|
||||
is_dest_haltestelle = dest_type == LocationType.HALTESTELLE
|
||||
|
||||
Reference in New Issue
Block a user