Esempio n. 1
0
 def test_SearchBetterRoute(self):
     api = Main('input-file.csv')
     api.openningFile()
     search = Search()
     self.assertEqual(['GRU-BRC-SCL-ORL-CDG', 40],
                      search.better_price_travel(
                          route=routeOk, dataRoutes=api.dataFile.dataInput))
Esempio n. 2
0
 def test_SearchBetterRouteWrong(self):
     api = Main('input-file.csv')
     api.openningFile()
     search = Search()
     self.assertEqual(
         None,
         search.better_price_travel(route=routeWrong,
                                    dataRoutes=api.dataFile.dataInput))
Esempio n. 3
0
    def __init__(self, instancia, exibe_gera_arquivo=True):

        self.controller = None
        self.controller_da_interface = Main()
        # dados do grafo
        self.dados_do_arquivo = None
        self.dados_da_interface = None

        #configurações da janeça
        self.janela(instancia)

        # frame do titulo
        self.titleFrame = Frame(instancia)
        self.titleFrame.pack()

        self.title = Label(self.titleFrame)
        self.title['text'] = 'Trabalho de Grafos'
        self.title['font'] = ('Helvetica', '20')
        self.title['fg'] = '#666'
        self.title['pady'] = '15'
        self.title['bg'] = BACKGROUND
        self.title.pack()

        # frame do botão gerar aquivo
        self.ArquivoFrame = Frame(instancia)
        self.ArquivoFrame['bg'] = BACKGROUND
        self.ArquivoFrame['pady'] = '10'
        self.ArquivoFrame.pack()

        #  botao gera arquivo
        self.btnExec = Button(self.ArquivoFrame)
        self.btnExec['text'] = 'Gerar arquivo de saida'
        self.formata_button(self.btnExec, '#2C82C9')
        self.btnExec['command'] = self.algoritmos
        if exibe_gera_arquivo == True:
            self.btnExec.pack(side=LEFT)

        #  botao quadro comandos
        self.btnComandos = Button(self.ArquivoFrame)
        self.btnComandos['text'] = 'Executar algoritmos'
        self.formata_button(self.btnComandos, '#2C82C9')
        self.btnComandos['command'] = self.quadro_comandos

        # botao cria grafo
        self.btnCreate = Button(self.ArquivoFrame)
        self.btnCreate['text'] = 'Criar grafo'
        self.formata_button(self.btnCreate, '#2969B0')
        self.btnCreate['command'] = self.criar_grafo
        self.btnCreate.pack(side=LEFT)

        # resultado leitura arquivo
        self.algoritmosFrame = Frame(instancia)
        self.algoritmosFrame['pady'] = '15'
        self.algoritmosFrame['bg'] = BACKGROUND
        self.algoritmosFrame.pack()

        #container para criação do grafo
        self.grafoCreateFrame = Frame(instancia, bg=BACKGROUND, pady='10')

        # frames
        self.verticesFrame = Frame(self.grafoCreateFrame, bg=BACKGROUND)
        self.arestasFrame = Frame(self.grafoCreateFrame, bg=BACKGROUND)
        self.digrafoFrame = Frame(self.grafoCreateFrame, bg=BACKGROUND)
        self.pesoFrame = Frame(self.grafoCreateFrame, bg=BACKGROUND)
        self.btnCriaGrafo = Frame(self.grafoCreateFrame,
                                  bg=BACKGROUND,
                                  pady='15')

        # vertices
        self.verticesLabel = Label(self.verticesFrame,
                                   text="Vertices: ",
                                   bg=BACKGROUND)
        self.vertices = Entry(self.verticesFrame, bg=BACKGROUND)
        self.vertices.insert(0, "0 1 2 3")
        self.formata_entrada(self.vertices)

        self.verticesLabel.pack()
        self.vertices.pack()

        # arestas
        self.arestaLabel = Label(self.arestasFrame,
                                 text="Aresta: ",
                                 bg=BACKGROUND)
        self.aresta = Entry(self.arestasFrame, bg=BACKGROUND)
        self.aresta.insert(
            0, "[0 1 10], [1 2 11], [0 2 20], [2 3 12], [1 3 13], [2 0 14]")
        self.formata_entrada(self.aresta)

        self.arestaLabel.pack()
        self.aresta.pack()

        # digrafo
        self.digrafoLabel = Label(self.digrafoFrame,
                                  text="Digrafo: ",
                                  bg=BACKGROUND)
        self.digrafo = Entry(self.digrafoFrame, bg=BACKGROUND)
        self.digrafo.insert(0, "True")
        self.formata_entrada(self.digrafo)

        self.digrafoLabel.pack()
        self.digrafo.pack()

        # peso
        self.pesoLabel = Label(self.pesoFrame, text="Peso: ", bg=BACKGROUND)
        self.peso = Entry(self.pesoFrame, bg=BACKGROUND)
        self.peso.insert(0, "True")
        self.formata_entrada(self.peso)

        self.pesoLabel.pack()
        self.peso.pack()

        # botao cria grafo
        self.btnGeraGrafo = Button(self.btnCriaGrafo)
        self.btnGeraGrafo['text'] = 'Gerar Grafo'
        self.formata_button(self.btnGeraGrafo, '#FAC51C')
        self.btnGeraGrafo['command'] = self.gera_grafo

        # empacotando os frames
        self.verticesFrame.pack()
        self.arestasFrame.pack()
        self.digrafoFrame.pack()
        self.pesoFrame.pack()
        self.btnCriaGrafo.pack()

        # frame dos comandos
        self.comandosAlgoritmosFrame = Frame(instancia,
                                             bg=BACKGROUND,
                                             pady='10')

        # frames comandos
        self.boxAreaComandos = Frame(self.comandosAlgoritmosFrame,
                                     bg=BACKGROUND)
        self.frameBtninformarComandos = Frame(self.comandosAlgoritmosFrame,
                                              bg=BACKGROUND,
                                              pady='15')

        self.LabelAreaComandos = Label(self.boxAreaComandos,
                                       text="COMANDOS: ",
                                       bg=BACKGROUND)
        self.AreaComandos = Text(self.boxAreaComandos,
                                 bg='#f1f1f1',
                                 width='68',
                                 height='10')

        self.LabelAreaComandos.pack()
        self.AreaComandos.pack()

        self.btnInformarComandos = Button(self.frameBtninformarComandos)
        self.btnInformarComandos['text'] = 'Executar os comandos'
        self.formata_button(self.btnInformarComandos, '#FAC51C')
        self.btnInformarComandos['command'] = self.recebe_comando

        self.boxAreaComandos.pack()
        self.btnInformarComandos.pack()

        # frames comandos
        self.boxRespostasComandos = Frame(self.comandosAlgoritmosFrame,
                                          bg=BACKGROUND)

        # lista de respostas
        self.lista_respostas = []
Esempio n. 4
0
    if better_route is not None:
        print(f'best route: {better_route[0]} > ${better_route[1]}')
    else:
        print('Route not found')


if __name__ == '__main__':
    args = []

    for param in sys.argv:
        args.append(param)

    fileInput = args[1]

    api = Main(fileInput)
    api.openningFile()

    option = 3

    while option != 0:

        show()
        option = int(input('Enter with option: '))

        if (option == 1):
            createRoute()
        elif option == 2:
            searchRoute()
        elif option == 0:
            print('Exit')
Esempio n. 5
0
 def test_validateCreateRouteAmountNegative(self):
     api = Main('input-file.csv')
     api.openningFile()
     self.assertFalse(
         api.dataFile.writeFile(originEmpty, destinyEmpty, amountNegative))
Esempio n. 6
0
 def test_validateCreateRouteAmountZero(self):
     api = Main('input-file.csv')
     api.openningFile()
     self.assertFalse(
         api.dataFile.writeFile(originNull, destinyOk, amountZero))
Esempio n. 7
0
 def test_validateCreateRouteOriginEmpty(self):
     api = Main('input-file.csv')
     api.openningFile()
     self.assertFalse(
         api.dataFile.writeFile(originEmpty, destinyOk, amountOk))