-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput_links.py
More file actions
32 lines (21 loc) · 804 Bytes
/
output_links.py
File metadata and controls
32 lines (21 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from Subway import *
import collections
def main():
def station_filter(station):
# return True
return station.get_borough() == "M"
# Load the data from disk
system = SubwayLinkSystem("data", station_filter)
link_file = open("data/links.csv", "w")
trans_file = open("data/trans.csv", "w")
for station in system.get_stations():
station_id = station.get_id()
# Print ride connections
for conn in station.get_connecting_ride_stations():
link_file.write("%d,%d\n" % (station_id, conn.get_id()))
# Print transfer connections
for conn in station.get_connecting_transfer_stations():
trans_file.write("%d,%d\n" % (station_id, conn.get_id()))
print("Done!")
if __name__ == "__main__":
main()