A simple students project implementing Dinic's Algorithm to compute the max flow/min cut of a network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

  1. #include <iostream>
  2. #include "popl.hpp"
  3. #include "OptionParser.h"
  4. namespace parser {
  5. int printPoplException(const popl::invalid_option &e) {
  6. std::cerr << "Invalid Option Exception: " << e.what() << "\n";
  7. std::cerr << "error: ";
  8. if (e.error() == popl::invalid_option::Error::missing_argument) {
  9. std::cerr << "missing_argument\n";
  10. } else if (e.error() == popl::invalid_option::Error::invalid_argument) {
  11. std::cerr << "invalid_argument\n";
  12. } else if (e.error() == popl::invalid_option::Error::too_many_arguments) {
  13. std::cerr << "too_many_arguments\n";
  14. } else if (e.error() == popl::invalid_option::Error::missing_option) {
  15. std::cerr << "missing_option\n";
  16. }
  17. if (e.error() == popl::invalid_option::Error::missing_option) {
  18. std::string option_name(e.option()->name(popl::OptionName::short_name, true));
  19. if (option_name.empty())
  20. option_name = e.option()->name(popl::OptionName::long_name, true);
  21. std::cerr << "option: " << option_name << "\n";
  22. }
  23. else {
  24. std::cerr << "option: " << e.option()->name(e.what_name()) << "\n";
  25. std::cerr << "value: " << e.value() << "\n";
  26. }
  27. return EXIT_FAILURE;
  28. }
  29. int checkOption(const int input_filename_count,
  30. const int input_string_count) {
  31. if(input_filename_count > 1) {
  32. std::cerr << "You may only pass one input graph file.";
  33. return INPUT_ERROR;
  34. }
  35. if(input_string_count > 1) {
  36. std::cerr << "You may only pass one input graph string.";
  37. return INPUT_ERROR;
  38. }
  39. if(input_filename_count > 0 && input_string_count > 0) {
  40. std::cerr << "You may only pass either an input graph file or an input graph string.";
  41. return INPUT_ERROR;
  42. }
  43. if(input_filename_count == 0 && input_string_count == 0) {
  44. std::cerr << "You need to pass either and input graph file or an input graph string.";
  45. return INPUT_ERROR;
  46. }
  47. return INPUT_OK;
  48. }
  49. }