def test_sizeStack (self): """ """ self.stack = st.newStack(self.list_type) self.assertEqual (st.size(self.stack), 0) self.assertTrue (st.isEmpty(self.stack)) st.push (self.stack, self.book5) st.push (self.stack, self.book6) st.push (self.stack, self.book3) st.push (self.stack, self.book10) st.push (self.stack, self.book1) st.push (self.stack, self.book2) st.push (self.stack, self.book8) st.push (self.stack, self.book4) st.push (self.stack, self.book7) st.push (self.stack, self.book9) self.assertEqual (st.size(self.stack), 10)
def test_sizeStack(self): """ """ self.stack = st.newStack(self.list_type) self.assertEqual(st.size(self.stack), 0) self.assertTrue(st.isEmpty(self.stack)) st.push(self.stack, self.movie5) st.push(self.stack, self.movie6) st.push(self.stack, self.movie3) st.push(self.stack, self.movie10) st.push(self.stack, self.movie1) st.push(self.stack, self.movie2) st.push(self.stack, self.movie8) st.push(self.stack, self.movie4) st.push(self.stack, self.movie7) st.push(self.stack, self.movie9) self.assertEqual(st.size(self.stack), 10)
def test_sizeStack(): """ Se prueba la creacion de una cola y la relacion con el tamaño al ingresar datos """ stack = st.newStack(list_type) assert (st.size(stack) == 0) assert (st.isEmpty(stack)) st.push(stack, book5) st.push(stack, book6) st.push(stack, book3) st.push(stack, book10) st.push(stack, book1) st.push(stack, book2) st.push(stack, book8) st.push(stack, book4) st.push(stack, book7) st.push(stack, book9) assert st.size(stack) == 10
def test_error_pop(): """ Este test busca comprobar que es imposible eliminar un objeto de una pila vacia """ stack = st.newStack(list_type) assert (st.size(stack) == 0) assert (st.isEmpty(stack)) with pytest.raises(Exception): st.pop(stack)
def test_top_pop(): """ Este test prueba la creacion de una cola y que el orden de salida sea el correcto para la estructura en cuestion, y que el tamaño se reduzca para cada salida de objeto """ stack = st.newStack(list_type) assert st.size(stack) == 0 assert st.isEmpty(stack) st.push(stack, book5) st.push(stack, book6) st.push(stack, book3) st.push(stack, book10) st.push(stack, book1) st.push(stack, book2) st.push(stack, book8) st.push(stack, book4) st.push(stack, book7) st.push(stack, book9) total = st.size(stack) while not (st.isEmpty(stack)): top = st.top(stack) assert (st.pop(stack) == top) total -= 1 assert (total == st.size(stack))
def test_infoElements(): """ Este test busca confirmar que los datos se almacenen de forma correcta y que sean los valores correctos en el orden apropiado de la estructura. """ stack = st.newStack(list_type) assert (st.size(stack) == 0) assert (st.isEmpty(stack)) st.push(stack, book5) st.push(stack, book6) st.push(stack, book3) st.push(stack, book10) st.push(stack, book1) st.push(stack, book2) st.push(stack, book8) st.push(stack, book4) st.push(stack, book7) st.push(stack, book9) elem = st.top(stack) assert (st.size(stack) == 10) assert (elem == book9) elem = st.pop(stack) assert (st.size(stack) == 9) assert (elem == book9) elem = st.pop(stack) assert (st.size(stack) == 8) assert (elem == book7) elem = st.top(stack) assert (st.size(stack) == 8) assert (elem == book4) st.push(stack, book9) assert (st.size(stack) == 9) elem = st.top(stack) assert (elem == book9)
def test_infoElements(self): """ """ self.stack = st.newStack(self.list_type) self.assertEqual(st.size(self.stack), 0) self.assertTrue(st.isEmpty(self.stack)) st.push(self.stack, self.movie5) st.push(self.stack, self.movie6) st.push(self.stack, self.movie3) st.push(self.stack, self.movie10) st.push(self.stack, self.movie1) st.push(self.stack, self.movie2) st.push(self.stack, self.movie8) st.push(self.stack, self.movie4) st.push(self.stack, self.movie7) st.push(self.stack, self.movie9) elem = st.top(self.stack) self.assertEqual(st.size(self.stack), 10) self.assertDictEqual(elem, self.movie9) elem = st.pop(self.stack) self.assertEqual(st.size(self.stack), 9) self.assertDictEqual(elem, self.movie9) elem = st.pop(self.stack) self.assertEqual(st.size(self.stack), 8) self.assertDictEqual(elem, self.movie7) elem = st.top(self.stack) self.assertEqual(st.size(self.stack), 8) self.assertDictEqual(elem, self.movie4) st.push(self.stack, self.movie9) self.assertEqual(st.size(self.stack), 9) elem = st.top(self.stack) self.assertDictEqual(elem, self.movie9)
def test_infoElements (self): """ """ self.stack = st.newStack(self.list_type) self.assertEqual (st.size(self.stack), 0) self.assertTrue (st.isEmpty(self.stack)) st.push (self.stack, self.book5) st.push (self.stack, self.book6) st.push (self.stack, self.book3) st.push (self.stack, self.book10) st.push (self.stack, self.book1) st.push (self.stack, self.book2) st.push (self.stack, self.book8) st.push (self.stack, self.book4) st.push (self.stack, self.book7) st.push (self.stack, self.book9) elem = st.top (self.stack) self.assertEqual (st.size(self.stack), 10) self.assertDictEqual (elem, self.book9) elem = st.pop (self.stack) self.assertEqual (st.size(self.stack), 9) self.assertDictEqual (elem, self.book9) elem = st.pop (self.stack) self.assertEqual (st.size(self.stack), 8) self.assertDictEqual (elem, self.book7) elem = st.top (self.stack) self.assertEqual (st.size(self.stack), 8) self.assertDictEqual (elem, self.book4) st.push (self.stack, self.book9) self.assertEqual (st.size(self.stack), 9) elem = st.top (self.stack) self.assertDictEqual (elem, self.book9)
def test_push_pop(): """ Este test prueba que la cola pueda manejar inserciones y eliminaciones de forma correcta siguiendo un orden establecido, y que no quede referencia al objeto sacado despues de haberlo removido de la cola """ stack = st.newStack(list_type) assert (st.size(stack) == 0) assert (st.isEmpty(stack)) st.push(stack, book5) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book6) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book3) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book10) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book1) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book2) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book8) st.push(stack, book4) st.push(stack, book7) st.push(stack, book9) assert (st.size(stack) == 4) assert book9 == st.pop(stack) assert book7 == st.pop(stack) assert book4 == st.pop(stack) assert book8 == st.pop(stack) assert (st.size(stack) == 0)
g.insertVertex(graph, 'Bogota') g.insertVertex(graph, 'Yopal') g.insertVertex(graph, 'Cali') g.insertVertex(graph, 'Medellin') g.insertVertex(graph, 'Pasto') g.insertVertex(graph, 'Barranquilla') g.insertVertex(graph, 'Manizales') g.insertVertex(graph, 'Cucuta') g.insertVertex(graph, 'Bucaramanga') g.addEdge(graph, 'Bogota', 'Yopal', 1) g.addEdge(graph, 'Bogota', 'Medellin', 1) g.addEdge(graph, 'Bogota', 'Pasto', 1) g.addEdge(graph, 'Bogota', 'Cali', 1) g.addEdge(graph, 'Yopal', 'Medellin', 1) g.addEdge(graph, 'Medellin', 'Pasto', 1) g.addEdge(graph, 'Cali', 'Pasto', 1) g.addEdge(graph, 'Cali', 'Barranquilla', 1) g.addEdge(graph, 'Barranquilla', 'Manizales', 1) g.addEdge(graph, 'Pasto', 'Manizales', 1) g.addEdge(graph, 'Cucuta', 'Bucaramanga', 1) search = newBFS(graph, 'Bogota') print('A Cali', hasPathTo(search, 'Cali')) print('A Cucuta', hasPathTo(search, 'Cucuta')) pathManizales = pathTo(search, 'Manizales') print('BSF::roadToManizales', pathManizales) number = stk.size(pathManizales) print(number)