diff --git a/src/processing.py b/src/processing.py new file mode 100644 index 0000000..4336bf1 --- /dev/null +++ b/src/processing.py @@ -0,0 +1,33 @@ +from preprocessing import parse_file +from pandas import DataFrame +from secrets import randbelow +from sys import argv + + +def get_furthest_element(element, data): + element_df = data.query(f"source == {element} or destination == {element}") + furthest_index = element_df["distance"].idxmax() + furthest_row = data.iloc[furthest_index] + return furthest_row + + +def greedy_algorithm(n, m, data): + solutions = DataFrame(columns=["source", "destination", "distance"]) + for _ in range(m): + centroid = get_furthest_element(element=randbelow(n), data=data) + solutions = solutions.append(centroid) + + +def usage(argv): + print(f"Usage: python {argv[0]} ") + exit(1) + + +def main(): + if len(argv) != 2: + usage(argv) + n, m, data = parse_file(argv[1]) + + +if __name__ == "__main__": + main()