GEDLIB  1.0
Public Member Functions | List of all members
ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel > Class Template Reference

Provides the API of GEDLIB. More...

#include <ged_env.hpp>

Public Member Functions

 ~GEDEnv ()
 Destructor.
 
 GEDEnv ()
 Constructor.
 
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. More...
 
void set_edit_costs (EditCosts< UserNodeLabel, UserEdgeLabel > *edit_costs)
 Sets the edit costs to user defined edit costs. More...
 
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. More...
 
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. More...
 
void add_node (GEDGraph::GraphID graph_id, const UserNodeID &node_id, const UserNodeLabel &node_label)
 Adds a labeled node. More...
 
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. More...
 
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. More...
 
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. More...
 
std::vector< GEDGraph::GraphIDload_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. More...
 
void init (Options::InitType init_type=Options::InitType::EAGER_WITHOUT_SHUFFLED_COPIES)
 Initializes the environment. More...
 
void set_method (Options::GEDMethod method, const std::string &options=std::string(""))
 Sets the GEDMethod to be used by run_method(). More...
 
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. More...
 
void init_method ()
 Initializes the method specified by call to set_method().
 
std::pair< GEDGraph::GraphID, GEDGraph::GraphIDgraph_ids () const
 Provides access to the IDs of the graphs contained in the environment. More...
 
std::size_t num_graphs () const
 The number of graphs contained in the environment. More...
 
double get_lower_bound (GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
 Returns lower bound for edit distance between the input graphs. More...
 
double get_upper_bound (GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
 Returns upper bound for edit distance between the input graphs. More...
 
const NodeMapget_node_map (GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
 Returns node map between the input graphs. More...
 
double get_runtime (GEDGraph::GraphID g_id, GEDGraph::GraphID h_id) const
 Returns runtime. More...
 
double get_init_time () const
 Returns initialization time. More...
 
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. More...
 
ExchangeGraph< UserNodeID, UserNodeLabel, UserEdgeLabel > get_graph (GEDGraph::GraphID graph_id) const
 Returns ged::ExchangeGraph representation. More...
 
const std::string & get_graph_class (GEDGraph::GraphID graph_id) const
 Returns the graph class. More...
 
const std::string & get_graph_name (GEDGraph::GraphID graph_id) const
 Returns the graph name. More...
 
bool quasimetric_costs () const
 Checks if the edit costs are quasimetric. More...
 
std::size_t get_num_nodes (GEDGraph::GraphID graph_id) const
 Returns the number of nodes. More...
 
double get_avg_num_nodes () const
 Returns average number of nodes. More...
 

Detailed Description

template<class UserNodeID, class UserNodeLabel, class UserEdgeLabel>
class ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >

Provides the API of GEDLIB.

Template Parameters
UserNodeIDClass of user-specific node IDs.
UserNodeLabelClass of user-specific node labels. If nodes are unlabeled, use ged::NoLabel or define your own dummy label class.
UserEdgeLabelClass of user-specific edge labels. If edges are unlabeled, use ged::NoLabel or define your own dummy label class.

Definition at line 48 of file ged_data.hpp.

Member Function Documentation

◆ add_edge()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::add_edge ( GEDGraph::GraphID  graph_id,
const UserNodeID &  tail,
const UserNodeID &  head,
const UserEdgeLabel &  edge_label,
bool  ignore_duplicates = true 
)

Adds a labeled edge.

Parameters
[in]graph_idID of graph that has been added to the environment.
[in]tailThe user-specific ID of the tail of the edge that has to be added.
[in]headThe user-specific ID of the head of the edge that has to be added.
[in]edge_labelThe label of the vertex that has to be added. Set to ged::NoLabel() if template parameter UserEdgeLabel equals ged::NoLabel.
[in]ignore_duplicatesIf true, duplicate edges are ignores. Otherwise, an exception is thrown if an existing edge is added to the graph.

Definition at line 359 of file ged_env.ipp.

◆ add_graph()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
GEDGraph::GraphID ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]graph_nameThe name of the added graph. Empty if not specified.
[in]graph_classThe class of the added graph. Empty if not specified.
Returns
The ID of the newly added graph.

Definition at line 69 of file ged_env.ipp.

◆ add_node()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::add_node ( GEDGraph::GraphID  graph_id,
const UserNodeID &  node_id,
const UserNodeLabel &  node_label 
)

Adds a labeled node.

Parameters
[in]graph_idID of graph that has been added to the environment.
[in]node_idThe user-specific ID of the vertex that has to be added.
[in]node_labelThe label of the vertex that has to be added. Set to ged::NoLabel() if template parameter UserNodeLabel equals ged::NoLabel.

Definition at line 339 of file ged_env.ipp.

◆ clear_graph()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]graph_idID of graph that has to be cleared.

Definition at line 89 of file ged_env.ipp.

◆ compute_induced_cost()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]g_idID of input graph.
[in]h_idID of input graph.
[in,out]node_mapNode map whose induced edit cost is to be computed.

Definition at line 641 of file ged_env.ipp.

◆ get_avg_num_nodes()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
double ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_avg_num_nodes ( ) const

Returns average number of nodes.

Returns
Average number of nodes of the graphs contained in the environment.

Definition at line 592 of file ged_env.ipp.

◆ get_graph()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
ExchangeGraph< UserNodeID, UserNodeLabel, UserEdgeLabel > ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_graph ( GEDGraph::GraphID  graph_id) const

Returns ged::ExchangeGraph representation.

Parameters
graph_idID of the selected graph.
Returns
ged::ExchangeGraph representation of the selected graph.

Definition at line 610 of file ged_env.ipp.

◆ get_graph_class()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
const std::string & ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_graph_class ( GEDGraph::GraphID  graph_id) const

Returns the graph class.

Parameters
[in]graph_idID of an input graph that has been added to the environment.
Returns
Class of the input graph.

Definition at line 578 of file ged_env.ipp.

◆ get_graph_name()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
const std::string & ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_graph_name ( GEDGraph::GraphID  graph_id) const

Returns the graph name.

Parameters
[in]graph_idID of an input graph that has been added to the environment.
Returns
Name of the input graph.

Definition at line 603 of file ged_env.ipp.

◆ get_init_time()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
double ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_init_time ( ) const

Returns initialization time.

Returns
Runtime of the last call to init_method().

Definition at line 634 of file ged_env.ipp.

◆ get_lower_bound()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
double ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_lower_bound ( GEDGraph::GraphID  g_id,
GEDGraph::GraphID  h_id 
) const

Returns lower bound for edit distance between the input graphs.

Parameters
[in]g_idID of an input graph that has been added to the environment.
[in]h_idID of an input graph that has been added to the environment.
Returns
Lower bound computed by the last call to run_method() with arguments g_id and h_id.

Definition at line 534 of file ged_env.ipp.

◆ get_node_map()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
const NodeMap & ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_node_map ( GEDGraph::GraphID  g_id,
GEDGraph::GraphID  h_id 
) const

Returns node map between the input graphs.

Parameters
[in]g_idID of an input graph that has been added to the environment.
[in]h_idID of an input graph that has been added to the environment.
Returns
Node map computed by the last call to run_method() with arguments g_id and h_id.

Definition at line 556 of file ged_env.ipp.

◆ get_num_nodes()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
std::size_t ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_num_nodes ( GEDGraph::GraphID  graph_id) const

Returns the number of nodes.

Parameters
[in]graph_idID of an input graph that has been added to the environment.
Returns
Number of nodes in the graph.

Definition at line 585 of file ged_env.ipp.

◆ get_runtime()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
double ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_runtime ( GEDGraph::GraphID  g_id,
GEDGraph::GraphID  h_id 
) const

Returns runtime.

Parameters
[in]g_idID of an input graph that has been added to the environment.
[in]h_idID of an input graph that has been added to the environment.
Returns
Runtime of last call to run_method() with arguments g_id and h_id.

Definition at line 567 of file ged_env.ipp.

◆ get_upper_bound()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
double ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::get_upper_bound ( GEDGraph::GraphID  g_id,
GEDGraph::GraphID  h_id 
) const

Returns upper bound for edit distance between the input graphs.

Parameters
[in]g_idID of an input graph that has been added to the environment.
[in]h_idID of an input graph that has been added to the environment.
Returns
Upper bound computed by the last call to run_method() with arguments g_id and h_id.

Definition at line 545 of file ged_env.ipp.

◆ graph_ids()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
std::pair< GEDGraph::GraphID, GEDGraph::GraphID > ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::graph_ids ( ) const

Provides access to the IDs of the graphs contained in the environment.

Returns
Pair (ID of first graphs, ID of last graph + 1) of graph IDs. If both entries equal 0, the environment does not contain any graphs.

Definition at line 507 of file ged_env.ipp.

◆ init()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::init ( Options::InitType  init_type = Options::InitType::EAGER_WITHOUT_SHUFFLED_COPIES)

Initializes the environment.

Parameters
[in]init_typeSelect initialization type.

Definition at line 655 of file ged_env.ipp.

◆ load_exchange_graph()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
GEDGraph::GraphID ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]exchange_graphThe ged::ExchangeGraph graph that should be loaded.
[in]graph_idThe ID of a graph contained the environment (overwrite existing graph) or ged::undefined() (add new graph).
[in]graph_nameThe name of newly added graph. Empty if not specified. Has no effect unless graph_id equals ged::undefined().
[in]graph_classThe class of newly added graph. Empty if not specified. Has no effect unless graph_id equals ged::undefined().
Returns
The ID of the newly loaded graph.
Note
If graph_id is set to ged::undefined(), all graphs contained in the environment have to be re-initialized.

Definition at line 104 of file ged_env.ipp.

◆ load_gxl_graph()

template<class UserNodeID, class UserNodeLabel, class UserEdgeLabel>
GEDGraph::GraphID ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]file_nameComplete path to GXL file.
[in]node_typeSelect if nodes are labeled or unlabeled.
[in]edge_typeSelect if edges are labeled or unlabeled.
[in]irrelevant_node_attributesSet of node attributes that are irrelevant for the selected edit costs.
[in]irrelevant_edge_attributesSet of edge attributes that are irrelevant for the selected edit costs.
[in]graph_idThe ID of a graph contained the environment (overwrite existing graph) or ged::undefined() (add new graph).
[in]graph_classThe class of the added graph. Empty if not specified. Has no effect unless graph_id equals ged::undefined().
Returns
The ID of the newly loaded graph.
Note
If graph_id is set to ged::undefined(), all graphs contained in the environment have to be re-initialized.
Warning
Calls to this method create a compiler error unless the template parameters UserNodeID is set to ged::GXLUserNodeID and the template parameters UserNodeLabel and UserEdgeLabel are set to ged::GXLLabel.

◆ load_gxl_graphs()

template<class UserNodeID, class UserNodeLabel, class UserEdgeLabel>
std::vector<GEDGraph::GraphID> ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]graph_dirThe path to the directory containing the graphs.
[in]collection_fileThe path to a XML file thats lists the graphs contained in graph_dir that should be loaded.
[in]node_typeSelect if nodes are labeled or unlabeled.
[in]edge_typeSelect if edges are labeled or unlabeled.
[in]irrelevant_node_attributesSet of node attributes that are irrelevant for the selected edit costs.
[in]irrelevant_edge_attributesSet of edge attributes that are irrelevant for the selected edit costs.
Returns
A vector containing the IDs of the newly added graphs.
Warning
Calls to this method create a compiler error unless the template parameters UserNodeID is set to ged::GXLUserNodeID and the template parameters UserNodeLabel and UserEdgeLabel are set to ged::GXLLabel.

◆ num_graphs()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
std::size_t ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::num_graphs ( ) const

The number of graphs contained in the environment.

Returns
The number of graphs (without shuffled copies).

Definition at line 514 of file ged_env.ipp.

◆ quasimetric_costs()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
bool ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::quasimetric_costs ( ) const

Checks if the edit costs are quasimetric.

Returns
Boolean true if the edit costs are quasimetric and false, otherwise.

Definition at line 648 of file ged_env.ipp.

◆ run_method()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]g_idID of an input graph that has been added to the environment.
[in]h_idID of an input graph that has been added to the environment.

Definition at line 471 of file ged_env.ipp.

◆ set_edit_costs() [1/2]

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::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.

Parameters
[in]edit_costsSelect one of the predefined edit costs.
[in]edit_cost_constantsConstants passed to the constructor of the edit cost class selected by edit_costs.

Definition at line 55 of file ged_env.ipp.

◆ set_edit_costs() [2/2]

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::set_edit_costs ( EditCosts< UserNodeLabel, UserEdgeLabel > *  edit_costs)

Sets the edit costs to user defined edit costs.

Parameters
[in]edit_costsPointer to user defined edit costs. Must be freed by the user.

Definition at line 62 of file ged_env.ipp.

◆ set_method()

template<class UserNodeID , class UserNodeLabel , class UserEdgeLabel >
void ged::GEDEnv< UserNodeID, UserNodeLabel, UserEdgeLabel >::set_method ( Options::GEDMethod  method,
const std::string &  options = std::string("") 
)

Sets the GEDMethod to be used by run_method().

Parameters
[in]methodSelect the method that is to be used.
[in]optionsAn options string of the form "[--<option> <arg>] [...]" passed to the selected method.

Definition at line 384 of file ged_env.ipp.


The documentation for this class was generated from the following files: