27 #ifndef SRC_ENV_GED_ENV_HPP_ 28 #define SRC_ENV_GED_ENV_HPP_ 33 #include "../methods/all_methods.hpp" 48 template<
class UserNodeID,
class UserNodeLabel,
class UserEdgeLabel>
73 void set_edit_costs(EditCosts<UserNodeLabel, UserEdgeLabel> * edit_costs);
105 void add_edge(
GEDGraph::GraphID graph_id,
const UserNodeID & tail,
const UserNodeID & head,
const UserEdgeLabel & edge_label,
bool ignore_duplicates =
true);
133 const std::unordered_set<std::string> & irrelevant_node_attributes,
const std::unordered_set<std::string> & irrelevant_edge_attributes,
GEDGraph::GraphID graph_id =
ged::undefined(),
const std::string & graph_class =
"");
147 std::vector<GEDGraph::GraphID>
load_gxl_graphs(
const std::string & graph_dir,
const std::string & collection_file,
149 const std::unordered_set<std::string> & irrelevant_node_attributes = std::unordered_set<std::string>(),
const std::unordered_set<std::string> & irrelevant_edge_attributes = std::unordered_set<std::string>());
181 std::pair<GEDGraph::GraphID, GEDGraph::GraphID>
graph_ids()
const;
279 std::vector<GEDGraph::GraphID> new_graph_ids_;
281 GEDData<UserNodeLabel, UserEdgeLabel> ged_data_;
285 std::map<std::pair<GEDGraph::GraphID, GEDGraph::GraphID>,
double> lower_bounds_;
287 std::map<std::pair<GEDGraph::GraphID, GEDGraph::GraphID>,
double> upper_bounds_;
289 std::map<std::pair<GEDGraph::GraphID, GEDGraph::GraphID>,
Seconds> runtimes_;
291 std::map<std::pair<GEDGraph::GraphID, GEDGraph::GraphID>, NodeMap> node_maps_;
293 std::vector<std::map<UserNodeID, GEDGraph::NodeID>> original_to_internal_node_ids_;
295 std::vector<std::map<GEDGraph::NodeID, UserNodeID>> internal_to_original_node_ids_;
297 GEDMethod<UserNodeLabel, UserEdgeLabel> * ged_method_;
299 void read_gxl_label_from_ptree_(
const boost::property_tree::ptree::value_type & node_or_edge,
const std::unordered_set<std::string> & irrelevant_attributes,
const std::string & file,
GXLLabel & label);
305 std::string to_string_(UserNodeID node_id);
315 #ifdef GXL_GEDLIB_SHARED 316 #ifndef SRC_ENV_GED_ENV_GXL_CPP_ 317 extern template class GEDEnv<GXLNodeID, GXLLabel, GXLLabel>;
GEDGraph::GraphID load_gxl_graph(const std::string &file_name, Options::GXLNodeEdgeType node_type, Options::GXLNodeEdgeType edge_type, const std::unordered_set< std::string > &irrelevant_node_attributes, const std::unordered_set< std::string > &irrelevant_edge_attributes, GEDGraph::GraphID graph_id=ged::undefined(), const std::string &graph_class="")
Load graph given in the GXL file format.
std::size_t num_graphs() const
The number of graphs contained in the environment.
bool quasimetric_costs() const
Checks if the edit costs are quasimetric.
ged::GEDEnv class definition.
std::pair< GEDGraph::GraphID, GEDGraph::GraphID > graph_ids() const
Provides access to the IDs of the graphs contained in the environment.
std::vector< GEDGraph >::size_type GraphID
Type of internally used graph IDs.
ged::NodeMap class declaration.
void init(Options::InitType init_type=Options::InitType::EAGER_WITHOUT_SHUFFLED_COPIES)
Initializes the environment.
ExchangeGraph< UserNodeID, UserNodeLabel, UserEdgeLabel > get_graph(GEDGraph::GraphID graph_id) const
Returns ged::ExchangeGraph representation.
ged::GEDGraph class declaration.
GEDGraph::GraphID load_exchange_graph(const ged::ExchangeGraph< UserNodeID, UserNodeLabel, UserEdgeLabel > &exchange_graph, GEDGraph::GraphID graph_id=ged::undefined(), const std::string &graph_name="", const std::string &graph_class="")
Loads ged::ExchangeGraph into the environment.
std::vector< GEDGraph::GraphID > load_gxl_graphs(const std::string &graph_dir, const std::string &collection_file, Options::GXLNodeEdgeType node_type=Options::GXLNodeEdgeType::LABELED, Options::GXLNodeEdgeType edge_type=Options::GXLNodeEdgeType::LABELED, const std::unordered_set< std::string > &irrelevant_node_attributes=std::unordered_set< std::string >(), const std::unordered_set< std::string > &irrelevant_edge_attributes=std::unordered_set< std::string >())
Loads graphs given in the GXL file format.
double get_init_time() const
Returns initialization time.
Simple graph class used for communication with user.
void set_edit_costs(Options::EditCosts edit_costs, std::initializer_list< double > edit_cost_constants={})
Sets the edit costs to one of the predefined edit costs.
void init_method()
Initializes the method specified by call to set_method().
GEDMethod
Selects the method.
GXLNodeEdgeType
Selects whether nodes or edges of graphs given in GXL file format are labeled or unlabeled.
const std::string & get_graph_class(GEDGraph::GraphID graph_id) const
Returns the graph class.
double get_runtime(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
Returns runtime.
std::chrono::duration< double > Seconds
Internally used type for measurements in seconds.
InitType
Selects the initialization type of the environment.
double get_avg_num_nodes() const
Returns average number of nodes.
void add_node(GEDGraph::GraphID graph_id, const UserNodeID &node_id, const UserNodeLabel &node_label)
Adds a labeled node.
Type declarations used by various classes.
void compute_induced_cost(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id, NodeMap &node_map) const
Computes the edit cost between two graphs induced by a node map.
std::map< std::string, std::string > GXLLabel
Type of node and edge labels of graphs given in the .gxl file format.
double get_upper_bound(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
Returns upper bound for edit distance between the input graphs.
std::size_t get_num_nodes(GEDGraph::GraphID graph_id) const
Returns the number of nodes.
constexpr std::size_t undefined()
Returns undefined size.
void clear_graph(GEDGraph::GraphID graph_id)
Clears and de-initializes a graph that has previously been added to the environment. Call init() after calling this method.
void run_method(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id)
Runs the GED method specified by call to set_method() between the graphs with IDs g_id and h_id...
void set_method(Options::GEDMethod method, const std::string &options=std::string(""))
Sets the GEDMethod to be used by run_method().
Global namespace for GEDLIB.
void add_edge(GEDGraph::GraphID graph_id, const UserNodeID &tail, const UserNodeID &head, const UserEdgeLabel &edge_label, bool ignore_duplicates=true)
Adds a labeled edge.
Eager initialization, no shuffled graph copies are constructed.
EditCosts
Selects the edit costs.
const NodeMap & get_node_map(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
Returns node map between the input graphs.
ged::GEDData class declaration.
const std::string & get_graph_name(GEDGraph::GraphID graph_id) const
Returns the graph name.
GEDGraph::GraphID add_graph(const std::string &graph_name="", const std::string &graph_class="")
Adds a new uninitialized graph to the environment. Call init() after calling this method...
double get_lower_bound(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
Returns lower bound for edit distance between the input graphs.