Ejemplo n.º 1
0
def Req5Anexo(arbol):
    i = 0
    while i < 3:
        mayorVader = om.maxKey(arbol)
        evento = me.getValue(om.get(arbol, mayorVader))
        print('El evento con track_id:', evento['track_id'], 'con un Vader de',
              mayorVader)
        om.deleteMax(arbol)
        i += 1
def test_delete_max_min(tree):
    tree = om.put(tree, 23, 'book21')
    tree = om.put(tree, 7, 'book7')
    tree = om.put(tree, 30, 'book30')
    tree = om.put(tree, 5, 'book5')
    tree = om.put(tree, 4, 'book4')
    tree = om.put(tree, 3, 'book3')
    tree = om.put(tree, 20, 'book20')
    tree = om.put(tree, 25, 'book25')
    tree = om.put(tree, 35, 'book35')
    tree = om.put(tree, 29, 'book29')
    tree = om.put(tree, 11, 'book11')
    tree = om.put(tree, 15, 'book15')
    tree = om.put(tree, 10, 'book10')
    assert om.contains(tree, 3) is True
    assert om.size(tree) == 13
    om.deleteMin(tree)
    assert om.contains(tree, 3) is False
    assert om.size(tree) == 12
    assert om.contains(tree, 35) is True
    assert om.size(tree) == 12
    om.deleteMax(tree)
    assert om.contains(tree, 35) is False
    assert om.size(tree) == 11
Ejemplo n.º 3
0
def top3salida(analyzer):
    outree = om.newMap(omaptype="RBT", comparefunction=compareIds)
    pqiterator = it.newIterator(vertexNames(analyzer))
    while it.hasNext(pqiterator):
        vert = int(it.next(pqiterator))
        salidas = gr.outdegree(analyzer["graph"], str(vert))
        if not om.contains(outree, salidas):
            om.put(outree, salidas, str(vert))
        else:
            A = om.get(outree, salidas)
            B = me.getValue(A)
            om.put(outree, salidas, str(B)+","+str(vert))
    estaciones = lt.newList(datastructure="ARRAY_LIST")
    while lt.size(estaciones) < 3:
        val = om.get(outree, om.maxKey(outree))
        val1 = me.getValue(val)
        mayorsalida = val1.split(",")
        for i in mayorsalida:
            if lt.size(estaciones) < 3:
                K = m.get(analyzer["nameIndex"], i)
                L = me.getValue(K)
                lt.addLast(estaciones, L)
        om.deleteMax(outree)
    return estaciones
Ejemplo n.º 4
0
        tracemalloc.stop()
        delta_time = round(stop_time - start_time, 2)
        delta_memory = round(deltaMemory(start_memory, stop_memory), 2)

        #-------------------------------------------------
        hora_min = horas(str(hora_min))
        hora_max = horas(str(hora_max))
        print('Hay un total de', funcion[1], 'reproducciones entre', hora_min,
              'y', hora_max)
        print('=' * 30, 'Generos y reproducciones', '=' * 30)
        r = 1
        for i in range(om.size(funcion[2])):
            reps = om.maxKey(funcion[2])
            genero = me.getValue(om.get(funcion[2], reps))
            print('TOP ' + str(r) + ':', genero, 'con', reps, 'reps')
            om.deleteMax(funcion[2])
            r += 1
        print('El genero con más reps es', funcion[3], 'con',
              lt.size(me.getValue(mp.get(funcion[5], funcion[3]))), 'reps...')
        print('=' * 30, funcion[3].upper(), 'SENTIMENT ANALISIS', '=' * 30)
        print(funcion[3], 'tiene', funcion[4], 'tracks unicos..')
        print('Los top', lt.size(funcion[0]), 'tracks son:\n')
        r = 1
        for i in range(1, lt.size(funcion[0]) + 1):
            track_id = lt.getElement(funcion[0], i)[0]
            vader = lt.getElement(funcion[0], i)[2]
            hashtags = lt.getElement(funcion[0], i)[1]
            print('TOP ' + str(r) + ' track:', track_id, 'con', hashtags,
                  'hahtags y VADER =', vader)
            r += 1
        print("\nTiempo [ms]:", delta_time)