31 Mar '16, 9am

Planning Bus Trips with Python & Singapore's Smart Nation APIs

import sys import json import pprint start = sys.argv[1] end = sys.argv[2] print "loading JSON" stops = json.loads(open("stops.json").read()) services = json.loads(open("services.json").read()) routes = json.loads(open("routes.json").read()) print "Initializing tables" stop_desc_map = {stop["Description"]: stop for stop in stops} stop_code_map = {stop["BusStopCode"]: stop for stop in stops} routes_map = {} for route in routes: key = (route["ServiceNo"], route["Direction"]) if key not in routes_map: routes_map[key] = [] routes_map[key] += [route] print "Initializing Graph" graph = {} for service, path in routes_map.items(): for route_index in range(len(path) - 1): key = path[route_index]["BusStopCode"] if key not in graph: graph[key] = set() graph[path[route_index]["BusStopCode"]].add(path[route_index + 1]["BusStopCode"]) print "Running BFS" def bfs(graph, start, end): # ma...

Full article: http://www.lihaoyi.com/post/PlanningBusTripswithPythonSin...

Tweets

Singapore aims to become the world's first smart city-state

Singapore aims to become the world's first smar...

greenbiz.com 30 Mar '16, 10am

From the glass-walled conference room overlooking a minimalist two-story office just across the street from Facebook-owned...

Singapore smart city chief delivers vision to t...

computerweekly.com 01 Apr '16, 12pm

Culture matters in building smart cities Balakrishnan said the real determinant of success is culture. A society that embr...

#How to communicate stdout between Ruby and Pyt...

abizy.com 09 Apr '16, 12pm

We do not share, store or cache any illegal files on this blog. We only share digital contents those are licensed under “C...

Papua New Guinea First Nation to Submit Post-COP21 Climate Plan

Papua New Guinea First Nation to Submit Post-CO...

triplepundit.com 31 Mar '16, 9am

In fairness, this is a country where 90 percent of its people live in the informal economy, and live an existence without ...

@BusUsersUK ahem - how about a REAL bit of bus ...

reading-buses.co.uk 01 Apr '16, 1pm

In a date with destiny (May 19 2015 to be exact) we set a new land speed record for a service bus at the world renowned Mi...

Planing to shop for #furniture this weekend? Re...

iproperty.com.sg 01 Apr '16, 1pm

If you’re on the hunt for a feature wall or flooring solution, visit the GF+A Global showroom to take in the splendour of ...