27 #ifndef SRC_METHDOS_BRANCH_TIGHT_HPP_ 28 #define SRC_METHDOS_BRANCH_TIGHT_HPP_ 50 template<
class UserNodeLabel,
class UserEdgeLabel>
60 enum UpperBoundOption_ {NO, FIRST, LAST, BEST};
62 typedef boost::associative_property_map<GEDGraph::NodeNodeMap> MateMap_;
64 typedef std::map<std::size_t, std::size_t> SizeTSizeTMap_;
69 Weights_(std::size_t size_master);
71 double get_weight(std::size_t row_in_master, std::size_t col_in_master, std::size_t row_sub_in_master, std::size_t col_sub_in_master)
const;
73 void set_weight(std::size_t row_in_master, std::size_t col_in_master, std::size_t row_sub_in_master, std::size_t col_sub_in_master,
double weight);
76 std::size_t size_master_;
78 std::vector<double> weights_;
82 class SubproblemSolvers_ {
85 SubproblemSolvers_(std::size_t size_master, std::size_t degree);
87 LSAPSolver & solver(std::size_t row_in_master, std::size_t col_in_master);
89 const LSAPSolver & solver(std::size_t row_in_master, std::size_t col_in_master)
const;
91 DMatrix & subproblem(std::size_t row_in_master, std::size_t col_in_master);
93 const DMatrix & subproblem(std::size_t row_in_master, std::size_t col_in_master)
const;
95 SizeTSizeTMap_ & rows_subproblem_to_master(std::size_t row_in_master, std::size_t col_in_master);
97 std::size_t row_in_master(std::size_t row_in_master, std::size_t col_in_master, std::size_t row_in_subproblem)
const;
99 SizeTSizeTMap_ & cols_subproblem_to_master(std::size_t row_in_master, std::size_t col_in_master);
101 std::size_t col_in_master(std::size_t row_in_master, std::size_t col_in_master, std::size_t col_in_subproblem)
const;
103 std::size_t get_size()
const;
105 std::size_t get_degree()
const;
107 void solve(std::size_t num_threads);
109 void clear_solutions();
112 std::size_t size_master_;
116 std::vector<DMatrix> subproblems_;
118 std::vector<LSAPSolver> subproblem_solvers_;
120 std::vector<SizeTSizeTMap_> rows_sub_to_master_;
122 std::vector<SizeTSizeTMap_> cols_sub_to_master_;
128 KFactor_(std::size_t num_nodes);
130 bool contains_edge(std::size_t id_i, std::size_t id_k)
const;
132 void add_edge(std::size_t id_i, std::size_t id_k);
134 std::size_t num_nodes()
const;
139 std::size_t num_nodes_;
141 std::vector<bool> is_edge_;
144 std::size_t max_itrs_;
150 UpperBoundOption_ upper_bound_option_;
152 bool naive_regularization_;
154 std::size_t num_threads_;
156 double time_limit_in_sec_;
164 virtual bool ged_parse_option_(
const std::string & option,
const std::string & arg)
final;
170 bool termination_criterion_met_(
const std::size_t & current_itr,
const double & last_improvement,
Result & result);
172 void init_subproblems_(
const GEDGraph & g,
const GEDGraph & h, SubproblemSolvers_ & subproblem_solver)
const;
176 void update_master_problem_costs_(
const SubproblemSolvers_ & subproblems_solver,
const DMatrix & node_costs,
DMatrix & master_problem)
const;
178 void update_subproblem_costs_(
const Weights_ & weights, std::size_t degree, SubproblemSolvers_ & subproblems_solver)
const;
180 void update_weights_(
const LSAPSolver & master_problem_solver, std::size_t degree,
const SubproblemSolvers_ & subproblems_solver, Weights_ & weights)
const;
196 bool construct_transformed_complement_graph_(
const GEDGraph & complement_graph, std::size_t k,
GEDGraph & transformed_complement_graph,
GEDGraph::NodeNodeMap & transformed_to_original_nodes)
const;
std::map< NodeID, NodeID > NodeNodeMap
Map that assigns node IDs to node IDs.
Contains the standardized input data along with basic functionality.
virtual void ged_set_default_options_() final
Sets all options to default values.
virtual void ged_run_(const GEDGraph &g, const GEDGraph &h, Result &result) final
Runs the method with options specified by set_options().
std::map< NodeID, std::size_t > NodeSizeTMap
Map that assigns node IDs to integers.
A wrapper structure for the result of calls to ged::GEDMethod::run_as_util() and ged::GEDMethod::ged_...
Abstract class for the (suboptimal) computation of the graph edit distance.
Computes lower and upper bounds for general edit costs.
std::size_t LabelID
Internally used type of node and edge labels.
virtual bool ged_parse_option_(const std::string &option, const std::string &arg) final
Parses one option.
The normalized input graphs used by GEDLIB. All labels are integers.
Global namespace for GEDLIB.
This class solves LSAP instances by calling the library lsape available at https://bougleux.users.greyc.fr/lsape/.
virtual std::string ged_valid_options_string_() const
Returns string of all valid options.