human
I am working on the file "Slopes.ipynb".
The first task is:
We need to turn the map into a usable graph structure now!
Possible optimization: right now I have each node store its neighbors in IDs and as pointers. Since pointer dereferencing is slow, what we really want to do is to assign a zero-indexed ID to each node so it can be referenced in a list.
Can you write Python code for it?

=====
Here we really want to do is to assign a zero-indexed ID to each node so it can be referenced in a list?
assistant
#Here we really want to do is to assign a zero-indexed ID to each node so it can be referenced in a list.

# Todo add to node ititialziation

class Node:
    def __init__(self, node_id, lat, lng, is_stoplight, adj):
        self.node_id = node_id
        self.lat = lat
        self.lng = lng
        self.is_stoplight = is_stoplight
        self.adj = adj
        self.edge_coords = None
        self.edge_elevations = []
        self.edge_work = []
    def __lt__(self, other):
        return False
    def __gt__(self, other):
        return False
    def create_adj_node_ptrs(self):
        self.adj_node_ptrs = list(nodes[adj_node_id] for adj_node_id in self.adj)

# TODO support bridges
data['allow_bridges'] = False
data['banned_highway_types'] = [
    'motorway', 'trunk', 'service', 'steps', 'footway', 'pedestrian', 'sidewalk', 'path'
] 
                                # Also may include primary, secondary
# Highway type descriptions https://wiki.openstreetmap.org/wiki/Key:highway
#     motorway: interstate
#     trunk: mostly grade-separated state/us highways, always with medians
#     primary: major roads 
#     footway: exclusively pedestrians
#     sidewall: always on side of road
#     pedestrian: pedestrian oriented path, but not sidewalk
#     steps: stairsteps
#     path: trail
#     bridleway: horse trail
from collections import defaultdict
def map_to_graph(map_data):
    banned_types = set(data['banned_highway_types'])
    graph = defaultdict(set)
    for entry in map_data:
        if (entry['type'] == 'way'
                and 'data' in entry.keys()
                and 'tag' in entry['data'].keys()
                and 'highway' in entry['data']['tag'].keys()
                   ):
            highway_type = entry['data']['tag']['highway']
        else: # Is not labelled highway
            continue
        if (True
                and highway_type not in banned_types
                and (data['allow_bridges'] or ('bridge' not in entry['data']['tag']))
        ):
            road_nodes = entry['data']['nd']
            for i in range(len(road_nodes) - 1):
               ...