Package: algovis
Algovis is a python library made for visualizing algorithms. Refer to thedocumentationfor more info.Currently the library has these algorithmsSortingBubble SortInsertion SortSelection SortMerge SortQuick SortSearchingLinear SearchBinary SearchGetting StartedPrerequisitesI would highly suggest making a virtual environment. The main purpose of a Python virtual environments is to create an isolated environment for Python projects. You can read more about themhere.# making a test folder$mkdirtest_algovis# make it the current directory$cdtest_algovis# making a virtual environment (you can replace envname with whatever name you like)$python3-mvenvenvname# activating it$sourceenvname/bin/activateYou can only access algovis inside this virtual environment. To leave this virtual env when you're done trying out the library, type$deactivateInstalling$pip3installalgovisUsing the sorting packageVisualize method# import the sorting package from libraryfromalgovisimportsorting# importing random module to shuffle the listimportrandom# Making a list of 100 integers from 1-100# using list comprehensionmy_list=[i+1foriinrange(100)]# shuffling the listrandom.shuffle(my_list)# making a BubbleSort class object by passing the shuffled listbs_object=sorting.BubbleSort(my_list)# calling the visualize methodbs_object.visualize(interval=100)Outputsort method# lets work on a shorter example nowmy_list=[i+1foriinrange(10)]# shuffling the list using random modulerandom.shuffle(my_list)#making a quicksort objectqs_object=sorting.QuickSort(my_list)#sorting in reverse with stepsqs_object.sort(pivot="first",steps=True,reverse=True)evaluate method# calling the evaluate method and passing the optional parameter 'iterations'# the list is sorted 'iterations' number of times and the min, max and average time taken#to sort the list is returned in form of a formatted tablebs_object.evaluate(iterations=100)info method# This method gives us information about the algorithmbs_object.info()code method# It prints out the function for the algorithmbs_object.code()My terminal config is iTerm2 + ohmyzsh + powerlevel10k with dark backgroud. Colors may appear different in your terminal output. It's recommended to change the terminal color to something darkerUsing the searching packageThe searching package has the same methods as sorting, just instead of 'sort' you have 'search'
Refer to thedocumentationfor more infosearch method#importing searching packagefromalgovisimportsearching# making a list of integers from 1 to 100# using list comprehensionmy_list=[i+1foriinrange(100)]#making binary search objectbin_search=searching.BinarySearch(my_list)#calling the search methodbin_search.search(42,steps=True)visualize method# calling the visualize method# interval is the time between two different frames of the animationbin_search.visualize(42,interval=1000)# or if you want to linear search 42lin_search=searching.LinearSearch(my_list)# setting a less interval to make a much faster animationlin_search.visualize(42,interval=100)DoumentationThe documentation is built withMKdocsusingmaterialtheme and is hosted on netlify. You can read ithereAuthorMayank Arora(hotshot07)LicenseThis project is licensed under the GNU Affero General Public License v3 (AGPL-3.0) - see theLICENSEfile for details