-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.py
More file actions
23 lines (19 loc) · 854 Bytes
/
controller.py
File metadata and controls
23 lines (19 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import visualizer
import argparse
from sorting import Sorter
from util import *
"""Controls the circulation process between visualizer, sorting algorithms and plotter."""
def _get_args():
ap = argparse.ArgumentParser(description="Sorting algorithms visualization.")
ap.add_argument('-a', '--algorithm', type=str, help="Choose algorithm", required=True)
args = ap.parse_args()
return args.algorithm
algorithm = _get_args()
sorter = Sorter(enable_tracking=True)
sorting_functions = {'Selection': sorter.selection_sort, 'Insertion': sorter.insertion_sort,
'Bubble': sorter.bubble_sort, 'Heap': sorter.heap_sort,
'Quick': sorter.quick_sort, 'Merge': sorter.merge_sort}
func = sorting_functions.get(algorithm)
func(get_random_case(50, 10000))
vis = visualizer.Visualizer(sorter.track)
vis.start()