diff --git a/src/main.py b/src/main.py index 45c47cb663ca80a383d979d77ce637686c84f0b7..04708cac7f48736ad8d54339326d426ef4fe30c8 100644 --- a/src/main.py +++ b/src/main.py @@ -6,6 +6,19 @@ from pulp import * # Erstellen eines Graphen zur Bestimmung der Knotenreihenfolge from collections import defaultdict, deque +import argparse +def main(): + parser = argparse.ArgumentParser(description="Given a bi-partite graph this program will return a permutation of the second partition (called B or Y) so that the crossings of the graph are minimized.") + parser.add_argument("-f", "--file", required=True, help="Path to the file or directory that holds the graph(s).") + args = parser.parse_args() + path = args.file + + if os.path.isfile(path): + solve_bipartite_minimization(path) + elif os.path.isdir(path): + process_directory(path) + else: + logging.error(f"The path '{path}' does not exist or is neither a file nor a directory.") # Erstelle einen FileHandler und einen StreamHandler file_handler = logging.FileHandler('logfile.log') @@ -188,11 +201,14 @@ def process_directory(directory_path): solve_bipartite_minimization(file_path) # Rufe die Verarbeitungsfunktion für jede .gr Datei auf logging.info(f"Verarbeitung abgeschlossen für {file_path}") -#directory_path = 'githubtests/tiny_test_set/instances/' -#directory_path = 'mytests/instances/' -#process_directory(directory_path) +# #directory_path = 'githubtests/tiny_test_set/instances/' +# #directory_path = 'mytests/instances/' +# #process_directory(directory_path) + +# #test_file = 'githubtests/tiny_test_set/instances/complete_4_5.gr' +# test_file = 'githubtests/medium_test_set/instances/10.gr' +# #test_file = 'mytests/instances/1.gr' +# solve_bipartite_minimization(test_file) -#test_file = 'githubtests/tiny_test_set/instances/complete_4_5.gr' -test_file = 'githubtests/medium_test_set/instances/10.gr' -#test_file = 'mytests/instances/1.gr' -solve_bipartite_minimization(test_file) +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/main_iterative_opt.py b/src/main_iterative_opt.py index 404fee8483222df707d1262e7acc628bffb3c28e..607fa9098e04bc50c8eeb8a48f51a6d6eec771c5 100644 --- a/src/main_iterative_opt.py +++ b/src/main_iterative_opt.py @@ -5,6 +5,20 @@ from datetime import datetime, timedelta from pulp import * from collections import defaultdict, deque +import argparse +def main(): + parser = argparse.ArgumentParser(description="Given a bi-partite graph this program will return a permutation of the second partition (called B or Y) so that the crossings of the graph are minimized.") + parser.add_argument("-f", "--file", required=True, help="Path to the file or directory that holds the graph(s).") + args = parser.parse_args() + path = args.file + + if os.path.isfile(path): + solve_bipartite_minimization(path) + elif os.path.isdir(path): + process_directory(path) + else: + logging.error(f"The path '{path}' does not exist or is neither a file nor a directory.") + # Erstelle einen FileHandler und einen StreamHandler file_handler = logging.FileHandler('logfile.log') console_handler = logging.StreamHandler() @@ -174,11 +188,14 @@ def process_directory(directory_path): solve_bipartite_minimization(file_path) logging.info(f"Verarbeitung abgeschlossen für {file_path}") -#directory_path = 'githubtests/tiny_test_set/instances/' -#directory_path = 'mytests/instances/' -#process_directory(directory_path) +# #directory_path = 'githubtests/tiny_test_set/instances/' +# #directory_path = 'mytests/instances/' +# #process_directory(directory_path) + +# #test_file = 'githubtests/tiny_test_set/instances/complete_4_5.gr' +# test_file = 'githubtests/medium_test_set/instances/10.gr' +# #test_file = 'mytests/instances/1.gr' +# solve_bipartite_minimization(test_file) -#test_file = 'githubtests/tiny_test_set/instances/complete_4_5.gr' -test_file = 'githubtests/medium_test_set/instances/10.gr' -#test_file = 'mytests/instances/1.gr' -solve_bipartite_minimization(test_file) +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/main_zykel.py b/src/main_zykel.py index c189ff4fef20d22a809749ac71370fe8edc17c6f..3af853a205fe695c2b1e7cf660ff43d2c7237e43 100644 --- a/src/main_zykel.py +++ b/src/main_zykel.py @@ -6,6 +6,19 @@ from pulp import * # Erstellen eines Graphen zur Bestimmung der Knotenreihenfolge from collections import defaultdict, deque +import argparse +def main(): + parser = argparse.ArgumentParser(description="Given a bi-partite graph this program will return a permutation of the second partition (called B or Y) so that the crossings of the graph are minimized.") + parser.add_argument("-f", "--file", required=True, help="Path to the file or directory that holds the graph(s).") + args = parser.parse_args() + path = args.file + + if os.path.isfile(path): + solve_bipartite_minimization(path) + elif os.path.isdir(path): + process_directory(path) + else: + logging.error(f"The path '{path}' does not exist or is neither a file nor a directory.") # Erstelle einen FileHandler und einen StreamHandler file_handler = logging.FileHandler('logfile.log') @@ -213,11 +226,14 @@ def process_directory(directory_path): solve_bipartite_minimization(file_path) # Rufe die Verarbeitungsfunktion für jede .gr Datei auf logging.info(f"Verarbeitung abgeschlossen für {file_path}") -#directory_path = 'githubtests/tiny_test_set/instances/' -#directory_path = 'mytests/instances/' -#process_directory(directory_path) +# #directory_path = 'githubtests/tiny_test_set/instances/' +# #directory_path = 'mytests/instances/' +# #process_directory(directory_path) + +# #test_file = 'githubtests/tiny_test_set/instances/complete_4_5.gr' +# test_file = 'githubtests/medium_test_set/instances/10.gr' +# #test_file = 'mytests/instances/1.gr' +# solve_bipartite_minimization(test_file) -#test_file = 'githubtests/tiny_test_set/instances/complete_4_5.gr' -test_file = 'githubtests/medium_test_set/instances/10.gr' -#test_file = 'mytests/instances/1.gr' -solve_bipartite_minimization(test_file) +if __name__ == "__main__": + main() \ No newline at end of file