Beispiel #1
0
def newCatalog():
    """
    Inicializa el catálogo y retorna el catalogo inicializado.
    """
    #Creamos un mapa de ciudades
    cityStationsMap = map.newMap(capacity=5,
                                 prime=3,
                                 maptype='CHAINING',
                                 comparefunction=compareByKey)
    #Creamos un mapa de nombres de estaciones indexadas por Id de estación, para facilitar la carga de los datos de los otros archivos
    stationIdName = map.newMap(capacity=70,
                               prime=37,
                               maptype='CHAINING',
                               comparefunction=compareByKey)
    #stationNameId = map.newMap(capacity=70, prime=37, maptype='CHAINING',comparefunction=compareByKey)
    #Creamos un RBT indexado por fechas, el value es un map con ciudades y cantidad de viajes
    date_city_trips = tree.newMap('RBT')
    #Creamos una lista para que contiene dia, temperatura y cantidad de viajes en ese dia
    list_temperature = lt.newList('ARRAY_LIST')
    #Creamos un grafo de viajes por fecha
    trips_digraph = g.newGraph(44679,
                               compareByKey,
                               directed=True,
                               datastructure="ADJ_LIST")
    #Se crea el catálogo
    catalog = {
        'cities': cityStationsMap,
        'stationIds': stationIdName,
        'date_city_trips': date_city_trips,
        'list_temperature': list_temperature,
        'tripsGraph': trips_digraph
    }
    return catalog
Beispiel #2
0
def newGraph(size, cmpfunction, directed):
    """
    Crea un grafo vacio. Los vertices son guardados en un map de tipo linear probing
    """
    try:
        prime = nextPrime(size * 2)
        graph = {
            'vertices': None,
            'edges': 0,
            'type': 'ADJ_LIST',
            'comparefunction': cmpfunction,
            'directed': directed,
            'indegree': None
        }

        graph['vertices'] = map.newMap(capacity=prime,
                                       maptype='PROBING',
                                       comparefunction=cmpfunction)

        if (directed):
            graph['indegree'] = map.newMap(capacity=prime,
                                           maptype='PROBING',
                                           comparefunction=cmpfunction)
        return graph

    except Exception as e:
        return None
Beispiel #3
0
def newCatalog():
    """
    Inicializa el catálogo de peliculas. Retorna el catalogo inicializado.
    """
    catalog = {'booksList': None, 'authors': None, 'booksMap': None}
    catalog['booksList'] = lt.newList("ARRAY_LIST")
    catalog['booksMap'] = map.newMap(5003, maptype='CHAINING')  #10000 books
    catalog['authors'] = map.newMap(12007, maptype='PROBING')  #5841 authors
    return catalog
Beispiel #4
0
def newCatalog():
    """
    Inicializa el catálogo y retorna el catalogo inicializado.
    """
    libgraph = g.newGraph(7235,compareByKey,directed=True)
    rgraph = g.newGraph(111353,compareByKey)
    prime = 111353 * 2
    marcas_dfs= map.newMap(11000, maptype='PROBING',comparefunction=compareByKey)
    path_dfs=lt.newList()
    catalog = {'librariesGraph':libgraph, 'delayGraph':rgraph, 'visitedMap':None, 'marcas_dfs':marcas_dfs, 'marcas_bfs':None, 'path_dfs':path_dfs}
    catalog['visitedMap'] = map.newMap(prime, maptype='PROBING',comparefunction=compareByKey)    
    return catalog
Beispiel #5
0
def newCatalog():
    """
    Inicializa el catálogo y retorna el catalogo inicializado.
    """
    catalog = {}
    catalog['map_station'] = map.newMap(numelements=11,
                                        comparefunction=compareByKey)
    catalog['list_temepratura'] = lt.newList(datastructure='ARRAY_LIST')
    catalog['map_city_req2'] = map.newMap(comparefunction=compareByKey)
    catalog['fecha_tally_viajes'] = map.newMap(numelements=737,
                                               comparefunction=compareByKey)
    catalog['grafo'] = g.newGraph(7235, compareByKey, directed=True)
    return catalog
    def test_kosaraju(self):

        graph = g.newGraph(12, self.comparenames, directed=True)
        idscc = m.newMap(12,
                         maptype='PROBING',
                         comparefunction=self.comparenames)

        pre = q.newQueue()
        post = q.newQueue()
        reversepost = s.newStack()
        marked = m.newMap(12, comparefunction=self.comparenames)

        grmarked = m.newMap(12,
                            maptype='PROBING',
                            comparefunction=self.comparenames)
        grpre = q.newQueue()
        grpost = q.newQueue()
        grreversepost = s.newStack()

        # se inicializa el grafo
        self.loadgraph(graph)
        self.assertEqual(g.numVertex(graph), 12)
        self.assertEqual(g.numEdges(graph), 14)

        # Se calcula el grafo reverso de G
        greverse = self.reverse(graph)
        self.assertEqual(g.numVertex(greverse), 12)
        self.assertEqual(g.numEdges(greverse), 14)

        # Se recorre el grafor reverso de G, utilizando DepthFirstOrder.
        self.dfo(greverse, grmarked, grpre, grpost, grreversepost)
        lst = self.lstReversePost(grreversepost)

        #lst contiene los vertices retornados por reversepost (G-reverso)
        #Se recorre el grafo en el orden dado por reverspost (G-reverso)
        iterlst = it.newIterator(lst)
        scc = 1
        while (it.hasNext(iterlst)):
            vert = it.next(iterlst)
            if not m.contains(marked, vert):
                self.sccCount(graph, vert, marked, idscc, scc)
                scc += 1

        self.assertTrue(self.stronglyConnected(idscc, 'Pedro', 'Maria'))
        self.assertTrue(self.stronglyConnected(idscc, 'Martin', 'Gloria'))
        self.assertTrue(self.stronglyConnected(idscc, 'Susana', 'Tere'))

        self.assertFalse(self.stronglyConnected(idscc, 'Pedro', 'Gloria'))
        self.assertFalse(self.stronglyConnected(idscc, 'Camila', 'Jose'))
        self.assertFalse(self.stronglyConnected(idscc, 'Gloria', 'Luz'))
Beispiel #7
0
def newCatalog():
    """
    Inicializa el catálogo de peliculas. Retorna el catalogo inicializado.
    """

    catalog = {'moviesList': None, 'directors': None, 'moviesMap': None}
    catalog['moviesList'] = lt.newList("ARRAY_LIST")
    #catalog['moviesMap'] = map.newMap (1009, maptype='CHAINING')#2000 movies-smallfile
    #catalog['directors'] = map.newMap (4001, maptype='PROBING') #2000 directors-smallfile
    catalog['moviesMap'] = map.newMap(
        164531, maptype='CHAINING')  #329044 movies-bigfile
    catalog['directors'] = map.newMap(
        171863, maptype='PROBING')  #85929 directors-bigfile

    return catalog
Beispiel #8
0
def addDate_city_trips(catalog, row):
    '''
    Función que construye el árbol RBT de fechas. Cada nodo del árbol es a su vez un mapa de hash con cantidad de viajes indexados por ciudad
    '''
    # Añadimos las fechas al RBT con un value igual a un map con ciudad y values =  cantidad de viajes

    d = row['start_date']  # row del archivo trip.csv
    t = d.split(" ")[0]
    date = strToDate(t, '%m/%d/%Y')
    #print(date)
    id_station = row['start_station_id']
    city_trip = tree.get(catalog['date_city_trips'], date, greater)
    #print(city_trip)
    city = station_id_city(catalog, id_station)
    if city_trip:
        if map.contains(city_trip, city):
            u = map.get(city_trip, city)['value']
            u += 1
            map.put(city_trip, city, u)
            catalog['date_city_trips'] = tree.put(catalog['date_city_trips'],
                                                  date, city_trip, greater)

        else:
            map.put(city_trip, city, 1)
            catalog['date_city_trips'] = tree.put(catalog['date_city_trips'],
                                                  date, city_trip, greater)
    else:
        city_trip = map.newMap(capacity=5,
                               prime=3,
                               maptype='CHAINING',
                               comparefunction=compareByKey)
        map.put(city_trip, city, 1)
        catalog['date_city_trips'] = tree.put(catalog['date_city_trips'], date,
                                              city_trip, greater)
Beispiel #9
0
def prueba(grafo, origen):
    """ Me retorna el map de los revisados a partir del origen"""
    m = map.newMap(capacity=10,
                   comparefunction=grafo['comparefunction'],
                   maptype='CHAINING')
    newDFS_2(grafo, origen, m)
    return m
Beispiel #10
0
def newDijkstra(graph, s):
    """
    Crea una busqueda Dijkstra para un digrafo y un vertice origen
    """
    prime = nextPrime (g.numVertex(graph) * 2)
    search = {'graph':graph, 's':s, 'visitedMap':None, 'minpq':None}
    search['visitedMap'] = map.newMap(numelements=prime, maptype='PROBING', comparefunction=graph['comparefunction'])
    vertices = g.vertices (graph)
    itvertices = it.newIterator (vertices)
    while (it.hasNext (itvertices)):
        vert =  it.next (itvertices)
        map.put (search['visitedMap'], vert, {'marked':False,'edgeTo':None,'distTo':math.inf})
    map.put(search['visitedMap'], s, {'marked':True,'edgeTo':None,'distTo':0})
    pq = minpq.newIndexMinPQ(g.numVertex(graph), comparenames)
    search['minpq'] = pq
    minpq.insert(search['minpq'], s, 0)
    while not minpq.isEmpty(search['minpq']):
        v = minpq.delMin(pq)
        if not g.containsVertex(graph,v):
            raise Exception("Vertex ["+v+"] is not in the graph")
        else:
            adjs = g.adjacentEdges(search['graph'],v)
            adjs_iter = it.newIterator (adjs) 
            while (it.hasNext(adjs_iter)):
                w = it.next (adjs_iter)
                relax(search, w)


        # obtener los enlaces adjacentes de v
        # Iterar sobre la lista de enlaces
        # Relajar (relax) cada enlace
    return search
Beispiel #11
0
def getBooksCountByYearRange(catalog, years):
    """
    Retorna la cantidad de libros por rating para un rango de años
    """

    startYear = strToDate(years.split(" ")[0], '%Y-%m-%d')
    endYear = strToDate(years.split(" ")[1], '%Y-%m-%d')
    yearList = tree.valueRange(catalog['yearsTree'], startYear, endYear,
                               greater)
    counter = 0
    cities = map.newMap(40009, maptype='PROBING')
    if yearList:
        iteraYear = it.newIterator(yearList)
        while it.hasNext(iteraYear):
            yearElement = it.next(iteraYear)
            #print(yearElement['year'],yearElement['count'])
            counter += yearElement['count']
            keys = map.keySet(yearElement['ratingMap'])
            for i in range(1, lt.size(keys)):
                city_key = lt.getElement(keys, i)
                city = map.get(cities, city_key, compareByKey)
                if city:
                    city['Accidentes'] += 1
                else:
                    ciudad = {'ciudad': city_key, 'Accidentes': 1}
                    map.put(cities, ciudad['ciudad'], ciudad, compareByKey)
        total = {'total_Accidentes': counter}
        map.put(cities, 'total', total, compareByKey)

        return cities
    return None
Beispiel #12
0
    def test_LoadTable(self):
        table_capacity = 171
        book_map = ht.newMap(capacity=table_capacity,
                             maptype='CHAINING',
                             comparefunction=self.compare_book_id)
        booksfile = cf.data_dir + 'GoodReads/books-small.csv'

        self.assertEqual(ht.size(book_map), 0)
        self.assertTrue(ht.isEmpty(book_map))

        input_file = csv.DictReader(open(booksfile))
        for book in input_file:
            ht.put(book_map, book['book_id'], book)

        self.assertEqual(ht.size(book_map), 149)
        self.assertTrue(ht.contains(book_map, '100'))

        entry = ht.get(book_map, '100')
        self.assertIsNotNone(entry)
        self.assertEqual(entry['value']['book_id'], '100')

        ht.remove(book_map, '100')
        self.assertEqual(ht.size(book_map), 148)
        self.assertFalse(ht.contains(book_map, '100'))

        lst_keys = ht.keySet(book_map)
        self.assertFalse(lt.isEmpty(lst_keys))
        self.assertEqual(lt.size(lst_keys), 148)

        lst_values = ht.valueSet(book_map)
        self.assertFalse(lt.isEmpty(lst_values))
        self.assertEqual(lt.size(lst_values), 148)
Beispiel #13
0
def newYear (year, row):
    """
    Crea una nueva estructura para almacenar los libros por año 
    """
    yearNode = {"year": year, "ratingMap":None,}
    yearNode ['ratingMap'] = map.newMap(11,maptype='CHAINING')
    intRating = round(float(row['average_rating']))
    map.put(yearNode['ratingMap'],intRating, 1, compareByKey)
    return yearNode
Beispiel #14
0
def newDate (date, row):
    """
    Crea una nueva estructura para almacenar los accidentes por fecha 
    """
    dateNode = {"date": date, "cityMap":None}
    dateNode ['cityMap'] = map.newMap(2999,maptype='CHAINING') #5966 ciudades
    city = row['City']
    map.put(dateNode['cityMap'],city,1, compareByKey)
    return dateNode
Beispiel #15
0
def newDate (date, row):
    """
    Crea una nueva estructura para almacenar los accidentes por fecha 
    """
    dateNode = {"date": date, "severityMap":None}
    dateNode ['severityMap'] = map.newMap(7,maptype='CHAINING')
    intSeverity = int(row['Severity'])
    map.put(dateNode['severityMap'],intSeverity,1, compareByKey)
    return dateNode
Beispiel #16
0
def newDFS(graph, source):
    """
    Crea una busqueda DFS para un grafo y un vertice origen
    """
    prime = nextPrime (g.numVertex(graph) * 2)
    search={'graph':graph, 's':source, 'visitedMap':None}   
    search['visitedMap'] = map.newMap(numelements=prime, maptype='PROBING', comparefunction=graph['comparefunction'])
    map.put(search['visitedMap'],source, {'marked':True,'edgeTo':None})
    dfs(search, source)
    return search
Beispiel #17
0
def newAccidentDate(catalog, row):
    accident = {
        "id": None,
        "Date": row["Start_Time"].split(" ")[0],
        "Severity": None
    }
    accident["id"] = lt.newList("ARRAY_LIST")
    accident["Severity"] = map.newMap()
    map.put(accident["Severity"], row["Severity"], 1, compareByKey)
    lt.addLast(accident['id'], row['ID'])

    return accident
Beispiel #18
0
def newCatalog():
    """
    Inicializa el catálogo de peliculas. Retorna el catalogo inicializado.
    """
    catalog = {
        'moviesList': None,
        'directors': None,
        'moviesMap': None,
        'actors': None
    }
    catalog['moviesList'] = lt.newList("ARRAY_LIST")
    catalog['moviesMap'] = map.newMap(100003, 109345121,
                                      maptype='CHAINING')  #peliculas 329044
    catalog['idMap'] = map.newMap(100003, 109345121, maptype='CHAINING')
    catalog['directors'] = map.newMap(171863, 109345121,
                                      maptype='PROBING')  #directores 85929
    catalog['actors'] = map.newMap(86959, 109345121,
                                   maptype='CHAINING')  #actores 260861
    catalog['genres'] = map.newMap(1187, 109345121,
                                   maptype='PROBING')  #géneros 591
    return catalog
Beispiel #19
0
def newCatalog():
    """
    Inicializa el catálogo de peliculas. Retorna el catalogo inicializado.
    """
    catalog = {
        'booksList': None,
        'authors': None,
        'booksMap': None,
        "moviesList": None,
        "moviesMap": None,
        "directors": None,
        "actors": None
    }
    catalog['booksList'] = lt.newList("ARRAY_LIST")
    catalog['booksMap'] = map.newMap(5003, maptype='CHAINING')  #10000 books
    catalog['authors'] = map.newMap(12007, maptype='PROBING')  #5841 authors

    catalog['moviesList'] = lt.newList("ARRAY_LIST")
    catalog['moviesMap'] = map.newMap(164531,
                                      maptype='CHAINING')  #329044 movies
    catalog['actors'] = map.newMap(130439, maptype='CHAINING')  #260861 actors
    catalog['directors'] = map.newMap(171863,
                                      maptype='PROBING')  #85929 directors
    catalog['genres'] = map.newMap(43, maptype='PROBING')  # 21 genres
    return catalog
Beispiel #20
0
def newCatalogMovies():
    """
    Inicializa el catálogo de peliculas. Retorna el catalogo inicializado.
    """
    catalog = {
        "genres": None,
        'moviesList': None,
        'directors': None,
        'moviesMapTitle': None,
        'moviesMapId': None,
        "actors": None
    }
    catalog['moviesList'] = lt.newList("ARRAY_LIST")
    catalog['moviesMapTitle'] = map.newMap(170003, maptype='CHAINING')
    catalog['moviesMapId'] = map.newMap(170003,
                                        maptype='CHAINING')  #329044 movies
    catalog['directorsName'] = map.newMap(175003,
                                          maptype='PROBING')  #85929 directors
    catalog['directorsId'] = map.newMap(175003,
                                        maptype='PROBING')  #85929 directors
    #catalog['actorsId']=map.newMap (131011, maptype='CHAINING')#260861 actors
    catalog['actorsName'] = map.newMap(131011,
                                       maptype='CHAINING')  #260861 actors
    catalog["genres"] = map.newMap(43, maptype="PROBING")  #21 genres

    return catalog
Beispiel #21
0
def newCatalog():
    """
    Inicializa el catálogo de peliculas. Retorna el catalogo inicializado.
    """
   
    catalog = {'moviesList':None, 'directors':None, 'moviesMap': None}
    #catalog['moviesList'] = lt.newList("ARRAY_LIST")
    
    #MAPAS PARA ARCHIVOS GRANDES:
    catalog['moviesMap'] = map.newMap (164531, maptype='CHAINING')#329044 movies-bigfile
    catalog['directors'] = map.newMap (171863, maptype='PROBING') #85929 directors-bigfile
    catalog['actors'] = map.newMap (130439, maptype='CHAINING') #260862 actors big-file
    catalog['titlesMap'] = map.newMap (164531, maptype='CHAINING') #329044 titles big-file
    catalog['id_directorMap'] = map.newMap (164531, maptype= 'CHAINING') #329044 ids big-file
    

    #MAPAS PARA ARCHIVOS PEQUEÑOS:
    #catalog['moviesMap'] = map.newMap (1009, maptype='CHAINING')#2000 movies-smallfile
    #catalog['directors'] = map.newMap (4001, maptype='PROBING') #2000 directors-smallfile
    #catalog['actors'] = map.newMap (2417, maptype='CHAINING') #4833 actors small-file
    #catalog['titlesMap'] = map.newMap (4001, maptype='PROBING') #2000 titles small-file
    #catalog['id_directorMap'] = map.newMap (4001, maptype= 'PROBING') #2000 ids small-file

    #MAPA GENER0S (IGUAL PARA ARCHIVOS GRANDES Y PEQUEÑOS):
    catalog['genres'] = map.newMap(41, maptype='PROBING') #20 genres
    return catalog
Beispiel #22
0
def newMinHeap(capacity, cmpFunction):

    pq = [None] * (capacity + 1)
    qpMap = map.newMap(capacity, comparefunction=cmpFunction)
    minPQ = {
        'pq': pq,
        'qpMap': qpMap,
        'maxCapacity': capacity,
        'size': 0,
        'cmpFunction': cmpFunction
    }

    return minPQ
Beispiel #23
0
def componentes_conectados(grafo):
    counter = 0
    vertices = g.vertices(grafo)
    graph_iter = it.newIterator(vertices)
    m = map.newMap(capacity=10,
                   maptype='CHAINING',
                   comparefunction=grafo['comparefunction'])
    while (it.hasNext(graph_iter)):
        n = it.next(graph_iter)
        visited_w = map.get(m, n)
        if visited_w == None:
            newDFS_2(grafo, n, m)
            counter += 1
    return counter
Beispiel #24
0
def newCatalog():
    """
    Inicializa el catálogo y retorna el catalogo inicializado.
    """
    rgraph = g.newGraph(5500, compareByKey)
    catalog = {'delayGraph': rgraph}
    marcas_dfs = map.newMap(capacity=11000,
                            maptype='PROBING',
                            comparefunction=compareByKey)
    path_dfs = lt.newList()
    catalog['marcas_dfs'] = marcas_dfs
    catalog['marcas_bfs'] = None
    catalog['path_dfs'] = path_dfs
    return catalog
Beispiel #25
0
def componentes_conectados(catalog):
    counter = 0
    grafo = catalog['non_directed_Graph']
    vertices = g.vertices(grafo)
    graph_iter = it.newIterator(vertices)
    m = map.newMap(capacity=55681,
                   maptype='CHAINING',
                   comparefunction=grafo['comparefunction'])
    while (it.hasNext(graph_iter)):
        n = it.next(graph_iter)
        visited_w = map.get(m, n)
        if visited_w == None:
            dfs.newDFS_2(grafo, n, m)
            counter += 1
    return counter
Beispiel #26
0
def newBFS(graph, source):
    """
    Crea una busqueda BFS para un grafo y un vertice origen
    """
    prime = 11000
    search = {'graph': graph, 's': source, 'visitedMap': None}
    search['visitedMap'] = map.newMap(prime,
                                      maptype='PROBING',
                                      comparefunction=compareByKey)
    map.put(search['visitedMap'], source, {
        'marked': True,
        'edgeTo': None,
        'nodo': source
    })
    bfs(search, source)
    return search
Beispiel #27
0
def newGraph(size, cmpfunction):
    """
    Crea un grafo vacio. Los vertices son guardados en un map de tipo linear probing
    """
    prime = nextPrime(size * 2)
    graph = {
        'vertices': None,
        'edges': 0,
        'type': 'ADJ_LIST',
        'comparefunction': cmpfunction
    }

    graph['vertices'] = map.newMap(capacity=prime,
                                   maptype='PROBING',
                                   comparefunction=cmpfunction)

    return graph
Beispiel #28
0
def componentes_conectados(catalog):
    counter = 0
    grafo = catalog['reviewGraph']
    vertices = g.vertices(grafo)
    graph_iter = it.newIterator(vertices)
    m = map.newMap(
        capacity=55681,
        maptype='CHAINING',
        comparefunction=grafo['comparefunction']
    )  # Se asume que hay 111353 nodos y asi se pone la capacidad de la tabla.
    while (it.hasNext(graph_iter)):
        n = it.next(graph_iter)
        visited_w = map.get(m, n)
        if visited_w == None:
            newDFS_2(grafo, n, m)
            counter += 1
    return counter
Beispiel #29
0
    def test_topological(self):

        graph = g.newGraph(10, self.comparenames, directed=True)
        pre = q.newQueue()
        post = q.newQueue()
        reversepost = s.newStack()
        marked = m.newMap(10, comparefunction=self.comparenames)

        g.insertVertex(graph, 'Calculo1')
        g.insertVertex(graph, 'Calculo2')
        g.insertVertex(graph, 'Diseno1')
        g.insertVertex(graph, 'Diseno2')
        g.insertVertex(graph, 'Electiva')
        g.insertVertex(graph, 'Fisica1')
        g.insertVertex(graph, 'Ingles')
        g.insertVertex(graph, 'IP1')
        g.insertVertex(graph, 'IP2')
        g.insertVertex(graph, 'ProyectoFinal')

        g.addEdge(graph, 'Calculo1', 'Calculo2')
        g.addEdge(graph, 'Calculo2', 'IP2')
        g.addEdge(graph, 'Calculo2', 'Fisica1')
        g.addEdge(graph, 'Diseno1', 'Diseno2')
        g.addEdge(graph, 'Diseno2', 'ProyectoFinal')
        g.addEdge(graph, 'Electiva', 'ProyectoFinal')
        g.addEdge(graph, 'Fisica1', 'Diseno2')
        g.addEdge(graph, 'Ingles', 'ProyectoFinal')
        g.addEdge(graph, 'IP1', 'Diseno1')
        g.addEdge(graph, 'IP1', 'IP2')

        self.assertEqual(g.numEdges(graph), 10)
        self.assertEqual(g.numVertex(graph), 10)

        #DFO

        lstvert = g.vertices(graph)
        vertiterator = it.newIterator(lstvert)
        while it.hasNext(vertiterator):
            vert = it.next(vertiterator)
            if not (m.contains(marked, vert)):
                self.dfs(graph, vert, marked, pre, post, reversepost)
        self.printTopological(reversepost)
Beispiel #30
0
def newYear(year, row):
    """
    Crea una nueva estructura para almacenar los libros por año 
    """
    yearNode = {
        "year": year,
        "ratingMap": None,
        "count": 1,
        'severity': None,
        'state': None
    }
    yearNode['severity'] = {1: 0, 2: 0, 3: 0, 4: 0}
    sev = int(row['Severity'])
    yearNode['severity'][sev] += 1
    yearNode['ratingMap'] = map.newMap(40009, maptype='PROBING')
    city = {'Ciudad': row['City'], 'Accidentes': 1}
    map.put(yearNode['ratingMap'], city['Ciudad'], city, compareByKey)

    yearNode['state'] = tree.newMap()
    estado = {'Estado': row['State'], 'Accidentes': 1}
    tree.put(yearNode['state'], estado['Estado'], estado, greater)
    return yearNode