def test_loading_CSV_y_ordenamiento(lst_books): """ Prueba que se pueda leer el archivo y que despues de relizar el sort, el orden este correcto """ element = lt.lastElement(lst_books) assert element['goodreads_book_id'] == '4374400' element = lt.firstElement(lst_books) assert element['goodreads_book_id'] == '2767052' sort.selectionSort(lst_books, less) tam = lt.size(lst_books) assert tam == 149 element = lt.lastElement(lst_books) assert element['goodreads_book_id'] == '22557272' element = lt.firstElement(lst_books) assert element['goodreads_book_id'] == '1'
def test_addFirst(lst, books): assert lt.isEmpty(lst) == True assert lt.size(lst) == 0 lt.addFirst(lst, books[1]) assert lt.size(lst) == 1 lt.addFirst(lst, books[2]) assert lt.size(lst) == 2 book = lt.firstElement(lst) assert book == books[2]
def test_addLast(slt, movies): assert lst.isEmpty(slt) == True assert lst.size(slt) == 0 lst.addLast(slt, movies[0]) assert lst.size(slt) == 1 lst.addLast(slt, movies[1]) assert lst.size(slt) == 2 movie = lst.firstElement(slt) assert movie == movies[0] movie = lst.lastElement(slt) assert movie == movies[1]
def countCC (graph): counter = 0 listVert = gs.vertices(graph) if not lt.isEmpty(listVert): counter = 1 source = lt.firstElement(listVert) search = newDFS(graph, source) vert_iter = it.newIterator(listVert) while (it.hasNext(vert_iter)): v = it.next (vert_iter) if not map.get(search['visitedMap'], v): map.put(search['visitedMap'], v, {'marked':True,'edgeTo':None}) dfs(search, v) counter+=1 return counter