You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.py 2.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Wed Apr 1 15:12:31 2020
  5. @author: ljia
  6. """
  7. def constant_node_costs(edit_cost_name):
  8. if edit_cost_name == 'NON_SYMBOLIC' or edit_cost_name == 'LETTER2' or edit_cost_name == 'LETTER':
  9. return False
  10. elif edit_cost_name == 'CONSTANT':
  11. return True
  12. else:
  13. raise Exception('Can not recognize the given edit cost. Possible edit costs include: "NON_SYMBOLIC", "LETTER", "LETTER2", "CONSTANT".')
  14. # elif edit_cost_name != '':
  15. # # throw ged::Error("Invalid dataset " + dataset + ". Usage: ./median_tests <AIDS|Mutagenicity|Letter-high|Letter-med|Letter-low|monoterpenoides|SYNTHETICnew|Fingerprint|COIL-DEL>");
  16. # return False
  17. # return True
  18. def mge_options_to_string(options):
  19. opt_str = ' '
  20. for key, val in options.items():
  21. if key == 'init_type':
  22. opt_str += '--init-type ' + str(val) + ' '
  23. elif key == 'random_inits':
  24. opt_str += '--random-inits ' + str(val) + ' '
  25. elif key == 'randomness':
  26. opt_str += '--randomness ' + str(val) + ' '
  27. elif key == 'verbose':
  28. opt_str += '--stdout ' + str(val) + ' '
  29. elif key == 'parallel':
  30. opt_str += '--parallel ' + ('TRUE' if val else 'FALSE') + ' '
  31. elif key == 'update_order':
  32. opt_str += '--update-order ' + ('TRUE' if val else 'FALSE') + ' '
  33. elif key == 'sort_graphs':
  34. opt_str += '--sort-graphs ' + ('TRUE' if val else 'FALSE') + ' '
  35. elif key == 'refine':
  36. opt_str += '--refine ' + ('TRUE' if val else 'FALSE') + ' '
  37. elif key == 'time_limit':
  38. opt_str += '--time-limit ' + str(val) + ' '
  39. elif key == 'max_itrs':
  40. opt_str += '--max-itrs ' + str(val) + ' '
  41. elif key == 'max_itrs_without_update':
  42. opt_str += '--max-itrs-without-update ' + str(val) + ' '
  43. elif key == 'seed':
  44. opt_str += '--seed ' + str(val) + ' '
  45. elif key == 'epsilon':
  46. opt_str += '--epsilon ' + str(val) + ' '
  47. elif key == 'inits_increase_order':
  48. opt_str += '--inits-increase-order ' + str(val) + ' '
  49. elif key == 'init_type_increase_order':
  50. opt_str += '--init-type-increase-order ' + str(val) + ' '
  51. elif key == 'max_itrs_increase_order':
  52. opt_str += '--max-itrs-increase-order ' + str(val) + ' '
  53. # else:
  54. # valid_options = '[--init-type <arg>] [--random_inits <arg>] [--randomness <arg>] [--seed <arg>] [--verbose <arg>] '
  55. # valid_options += '[--time_limit <arg>] [--max_itrs <arg>] [--epsilon <arg>] '
  56. # valid_options += '[--inits_increase_order <arg>] [--init_type_increase_order <arg>] [--max_itrs_increase_order <arg>]'
  57. # raise Exception('Invalid option "' + key + '". Options available = "' + valid_options + '"')
  58. return opt_str

A Python package for graph kernels, graph edit distances and graph pre-image problem.