27 #ifndef SRC_ENV_COMMON_TYPES_HPP_ 28 #define SRC_ENV_COMMON_TYPES_HPP_ 36 #include <initializer_list> 40 #include <unordered_set> 57 #include <boost/graph/adjacency_list.hpp> 58 #include <boost/graph/adjacency_matrix.hpp> 59 #include <boost/graph/copy.hpp> 60 #include <boost/graph/max_cardinality_matching.hpp> 61 #include <boost/property_tree/ptree.hpp> 62 #include <boost/property_tree/xml_parser.hpp> 66 #include <gurobi_c++.h> 70 #ifndef LSAPE_IndexType 71 #define LSAPE_IndexType std::size_t 76 #include <doublefann.h> 92 typedef std::chrono::duration<double>
Seconds;
97 typedef std::map<std::string, std::string>
GXLLabel;
105 template<
class Key,
class Value>
106 std::ostream & operator<<(std::ostream & os, const std::map<Key, Value> & map) {
108 for (
const auto & key_val : map) {
109 os <<
"(" << key_val.first <<
"," << key_val.second <<
") ";
130 constexpr
bool operator==(
NoLabel const &,
NoLabel const &) {
return true;}
136 constexpr LabelID
invalid_label() {
return std::numeric_limits<LabelID>::max();}
149 constexpr std::size_t
undefined() {
return std::numeric_limits<std::size_t>::max();}
155 constexpr
double pi() {
return 3.141592653589793238463;}
229 LAZY_WITHOUT_SHUFFLED_COPIES,
230 EAGER_WITHOUT_SHUFFLED_COPIES,
231 LAZY_WITH_SHUFFLED_COPIES,
232 EAGER_WITH_SHUFFLED_COPIES
244 switch (ged_method) {
252 os <<
"BRANCH_TIGHT";
255 os <<
"BRANCH_UNIFORM";
258 os <<
"BRANCH_COMPACT";
270 os <<
"ANCHOR_AWARE_GED";
291 os <<
"BIPARTITE_ML";
300 os <<
"SIMULATED_ANNEALING";
309 case Options::GEDMethod::F1:
312 case Options::GEDMethod::F2:
315 case Options::GEDMethod::COMPACT_MIP:
318 case Options::GEDMethod::BLP_NO_EDGE_LABELS:
319 os <<
"BLP_NO_EDGE_LABELS";
332 template<
class UserNodeID,
class UserNodeLabel,
class UserEdgeLabel>
struct ExchangeGraph {
346 std::map<std::pair<std::size_t, std::size_t>, UserEdgeLabel>
edge_labels;
353 #ifdef ENABLE_GRAPH_STREAMING 364 template<
class UserNodeID,
class UserNodeLabel,
class UserEdgeLabel>
365 std::ostream & operator<<(std::ostream & os, const ExchangeGraph<UserNodeID, UserNodeLabel, UserEdgeLabel> & graph) {
367 os <<
"\tid = " << graph.id <<
"\n";
368 os <<
"\tdirected = 0\n";
369 os <<
"\tnum_nodes = " << graph.num_nodes <<
"\n";
370 os <<
"\tnum_edges = " << graph.num_edges <<
"\n";
371 for (std::size_t node_id{0}; node_id < graph.num_nodes; node_id++) {
373 os <<
"\t\tinternal_id = " << node_id <<
"\n";
374 os <<
"\t\toriginal_id = \"" << graph.original_node_ids.at(node_id) <<
"\"\n";
375 os <<
"\t\tlabel = \"" << graph.node_labels.at(node_id) <<
"\"\n";
378 for (std::size_t tail_id{0}; tail_id < graph.num_nodes; tail_id++) {
379 for (std::size_t head_id{tail_id + 1}; head_id < graph.num_nodes; head_id++) {
380 if (graph.adj_matrix[node_id][head_id] == 1) {
382 os <<
"\t\tinternal_id_tail = " << tail_id <<
"\n";
383 os <<
"\t\tinternal_id_head = " << head_id <<
"\n";
384 os <<
"\t\tlabel = \"" << graph.edge_labels[std::make_pair(tail_id, head_id)] <<
"\"\n";
Computes a lower bound for general edit costs.
std::string GXLNodeID
Type of node IDs of graphs given in the .gxl file format.
std::size_t id
Internal ID of the graph.
Mixed integer linear programming formulation of the graph edit distance.
constexpr double pi()
Provides constant with double precision.
std::vector< std::vector< std::size_t > > adj_matrix
Adjacency matrix.
std::ostream & operator<<(std::ostream &os, const std::map< Key, Value > &map)
Streams std::map.
Selects ged::AnchorAwareGED.
Simple graph class used for communication with user.
ged::ProgressBar class declaration.
GEDMethod
Selects the method.
std::vector< UserNodeLabel > node_labels
The labels of all nodes.
GXLNodeEdgeType
Selects whether nodes or edges of graphs given in GXL file format are labeled or unlabeled.
std::vector< UserNodeID > original_node_ids
The original IDs of all nodes.
Selects ged::BranchTight.
std::size_t LabelID
Internally used type of node and edge labels.
std::chrono::duration< double > Seconds
Internally used type for measurements in seconds.
InitType
Selects the initialization type of the environment.
Selects ged::SimulatedAnnealing.
Edit costs for graphs contain in CMU dataset.
Selects ged::BipartiteML.
std::map< std::string, std::string > GXLLabel
Type of node and edge labels of graphs given in the .gxl file format.
constexpr LabelID invalid_label()
Returns an invalid label.
std::size_t num_nodes
The number of nodes. Nodes have IDs between 0 and num_nodes - 1.
std::size_t num_edges
The number of edges.
std::map< std::pair< std::size_t, std::size_t >, UserEdgeLabel > edge_labels
A hash map with a key-value pair ((internal_tail_id, internal_head_id), label) for each edge...
constexpr LabelID dummy_label()
Returns a dummy label.
constexpr std::size_t undefined()
Returns undefined size.
ged::Error class declaration.
ged::Timer class declaration.
Global namespace for GEDLIB.
EditCosts
Selects the edit costs.
Selects ged::BranchUniform.
Type of dummy labels for unlabeled nodes and edges.
Computes an upper bound for general edit costs.
Contains enums for options employed by ged::GEDEnv.
Mixed integer linear programming formulation of the graph edit distance.
Selects ged::BranchCompact.