GEDLIB is a C++ library for (suboptimally) computing edit distances between graphs using various state-of-the-art methods. GEDLIB allows you to build your graphs via the C++ API or load them from GXL files. Several benchmark datasets are distributed with GEDLIB. For these datasets, GEDLIB provides predefined edit cost functions. You can easily extend GEDLIB by implementing new edit cost functions or new methods for computing the graph edit distance. An extensive Doxygen documentation is availabe here.
The source code of GEDLIB is distributed under the GNU Lesser General Public License. If you want to use GEDLIB in a publication, please refer to the following papers:
GEDLIB uses the following external libraries:
$ brew install libomp
.<GUROBI_ROOT>
and activate your Gurobi licence as described in the Gurobi documentation. If you cannot obtain a licence for Gurobi, you can install GEDLIB without it. In this case, the methods which use mixed integer or linear programming are not available.After having installed CMake, Doxygen, OpenMP (under Mac OS), and, possibly, Gurobi, execute the script install.py
for installing GEDLIB and the external libraries distributed with GEDLIB:
python install.py [--help] [-h] [--doc] [--tests <arg>] [--gurobi <GUROBI_ROOT>] [--debug] [--clean] [--lib gxl|<indentifier>,<UserNodeID>,<UserNodeLabel>,<UserEdgeLabel>]
If you execute install.py
without any arguments, only the external libraries distributed with GEDLIB are installed.
--help
, -h
: Show help. --doc
: Build the Doxygen documentation.--tests <arg>
: Build test executables. Use the option --help
to display possible values of <arg>
.--gurobi <GUROBI_ROOT>
: Tell GEDLIB where to find your Gurobi installation.--debug
: Build in debug mode. --clean
: Delete the build directoy and update the makefile before the build.--lib gxl
: Build the shared library lib/libgxlgedlib.so
for usage with graphs given in the GXL file format.--lib <indentifier>,<UserNodeID>,<UserNodeLabel>,<UserEdgeLabel>
: Build the shared library lib/lib<indentifier>gedlib.so
for graphs with custom node ID, node label, and edge label types. For example, executing $ python install.py --lib mytypes,int,double,double
builds the shared library lib/libmytypesgedlib.so
for usage with graphs whose node IDs are of type int
and whose node and edge labels are of type double
.For building an application that uses GEDLIB as a header-only library, it suffices to execute the installation script install.py
without any options. Subsequently, carry out the following steps:
<GEDLIB_ROOT>
<GEDLIB_ROOT>/ext/boost.1.69.0
<GEDLIB_ROOT>/ext/eigen.3.3.4/Eigen
<GEDLIB_ROOT>/ext/nomad.3.8.1/src
<GEDLIB_ROOT>/ext/nomad.3.8.1/ext/sgtelib/src
<GEDLIB_ROOT>/ext/lsape.5/include
<GEDLIB_ROOT>/ext/libsvm.3.22
<GEDLIB_ROOT>/ext/fann.2.2.0/include
<GUROBI_ROOT>/mac64/include
<GUROBI_ROOT>/linux64/include
<GEDLIB_ROOT>/ext/nomad.3.8.1/lib
<GEDLIB_ROOT>/ext/libsvm.3.22
<GEDLIB_ROOT>/ext/fann.2.2.0/lib
<GUROBI_ROOT>/mac64/lib
<GUROBI_ROOT>/linux64/lib
<GEDLIB_ROOT>/ext/fann.2.2.0/lib/libdoublefann.2.dylib
<GEDLIB_ROOT>/ext/libsvm.3.22/libsvm.so
<GEDLIB_ROOT>/ext/nomad.3.8.1/libnomad.so
<GUROBI_ROOT>/mac64/lib/libgurobi80.so
and <GUROBI_ROOT>/mac64/lib/libgurobi_c++.a
<GUROBI_ROOT>/linux64/lib/libgurobi80.so
and <GUROBI_ROOT>/linux64/lib/libgurobi_c++.a
GUROBI
before including the header src/env/ged_env.hpp
.If you want to build an application that uses GEDLIB as a shared for graphs given as GXL files, make sure that you have installed GEDLIB with the option --lib gxl
. Subsequently, carry out the folowing steps:
<GEDLIB_ROOT>
<GEDLIB_ROOT>/ext/boost.1.69.0
<GEDLIB_ROOT>/ext/eigen.3.3.4/Eigen
<GEDLIB_ROOT>/ext/nomad.3.8.1/src
<GEDLIB_ROOT>/ext/nomad.3.8.1/ext/sgtelib/src
<GEDLIB_ROOT>/ext/lsape.5/include
<GEDLIB_ROOT>/ext/libsvm.3.22
<GEDLIB_ROOT>/ext/fann.2.2.0/include
<GUROBI_ROOT>/mac64/include
<GUROBI_ROOT>/linux64/include
<GEDLIB_ROOT>/lib
to your link directories.libgxlgedlib.so
.If you want to build an application that uses GEDLIB as a shared library for graphs with custom node ID, node label, and edge label types, make sure that you have installed GEDLIB with the option --lib <indentifier>,<UserNodeID>,<UserNodeLabel>,<UserEdgeLabel>
. Subsequently, carry out the folowing steps:
<GEDLIB_ROOT>/lib
to your link directories.lib<indentifier>gedlib.so
.In your source file, include the header src/env/ged_env.hpp
and create your environment object:
#include "src/env/ged_env.hpp"
ged::GEDEnv<UserNodeID, UserNodeLabel, UserEdgeLabel> env;
All functionality of GEDLIB is accessible via the environment class ged::GEDEnv
, whose template parameters UserNodeID
, UserNodeLabel
, and UserEdgeLabel
must be set to the types of the node IDs, the node labels, and the edge labels of your graphs. Use the member functions ged::GEDEnv::add_graph()
, ged::GEDEnv::add_node()
, and ged::GEDEnv::add_edge()
, and ged::GEDEnv::set_edit_costs()
for adding graphs and edit costs to the environment. Once you're done with this, call ged::GEDEnv::init()
to initialize the environment.
When you have initialized the environment, you are ready to run the GED methods. To select the method, call ged::GEDEnv::set_method()
. You can then initialize the selected method via ged::GEDEnv::init_method()
, and run it via ged::GEDEnv::run_method()
. Note that most method can be run also without initialization, but doing so typically has a negative impact on both runtime and accuracy. Use the member functions ged::GEDEnv::get_lower_bound()
, ged::GEDEnv::get_upper_bound()
, ged::GEDEnv::get_node_map()
, ged::GEDEnv::get_runtime()
, ged::GEDEnv::get_init_time()
, ged::GEDEnv::get_graph_class()
, and ged::GEDEnv::get_graph_name()
for accessing the results of your GED computations. Use ged::GEDEnv::quasimetric_costs()
to check if your edit costs are quasimetric on the graphs contained in your environment.
If you use GEDLIB with the template parameter UserNodeID
set to ged::GXLNodeID
a.k.a. std::string
and the template parameters UserNodeLabel
and UserEdgeLabel
set to ged::GXLLabel
a.k.a. std::map<std::string,std::string>
, GEDLIB offers additional functionality for loading graphs given in the GXL file format. For those graphs, you do not have to use the member functions ged::GEDEnv::add_graph()
, ged::GEDEnv::add_node()
, and ged::GEDEnv::add_edge()
for adding graphs to your environment. Instead, you can simply load all of them at once by one call to ged::GEDEnv::load_gxl_graphs()
.
If you want to use GEDLIB as a shared library for graphs given as GXL files, make sure that you have installed GEDLIB with the option --lib gxl
. In your source file, you have to define GXL_GEDLIB_SHARED
before including src/env/ged_env.hpp
:
#define GXL_GEDLIB_SHARED
#include "src/env/ged_env.hpp"
ged::GEDEnv<ged::GXLNodeID, ged::GXLLabel, ged::GXLLabel> env
// ...
If you want to use GEDLIB as a shared library for graphs with custom node ID, node label, and edge label types, make sure that you have installed GEDLIB with the option --lib <indentifier>,<UserNodeID>,<UserNodeLabel>,<UserEdgeLabel>
. In your source file, you have to define <IDENTIFIER>_GEDLIB_SHARED
before including src/env/ged_env.hpp
, where <IDENTIFIER>
is the upper case transformation of <identifier>
. For example, if you have installed GEDLIB by executing $ python install.py --lib mytypes,int,double,double
, you have to do the following:
#define MYTYPES_GEDLIB_SHARED
#include "src/env/ged_env.hpp"
ged::GEDEnv<int, double, double> env
// ...
For an extensively commented example of how to use GEDLIB, have a look at median/tests/median_letter_demo.cpp
. For more examples, see the .cpp
files contained in the sub-directories of the tests/
directory.
GEDLIB has been used for several research papers. For reproducing the experiments reported in these papers, follow the instructions below.
In order to reproduce the experiments reported in this paper, install GEDLIB with the option --tests sspr2018
. After installation, open a shell and execute the following commands:
$ cd <GEDLIB_ROOT>/tests/sspr2018/bin
$ ./learn_ring_params
$ ./learn_subgraph_depths
$ ./learn_walks_depth
$ ./test_lsape_based_methods
After having executed these commands, the results of the experiments are contained in the folder tests/sspr2018/output/
.
In order to reproduce the experiments reported in this paper, install GEDLIB with the options --tests vldbj2020
and --gurobi <GUROBI_ROOT>
. After installation, open a shell and execute the following commands:
$ cd <GEDLIB_ROOT>/tests/vldbj2020/bin
$ ./vldbj_train_subgraph
$ ./vldbj_train_walks
$ ./vldbj_train_ring
$ ./vldbj_train_ml
$ ./vldbj_test_lsape_based_methods
$ ./vldbj_test_lp_based_methods
$ ./vldbj_test_ls_based_methods
$ ./vldbj_test_misc_methods
$ ./vldbj_test_best_methods
After having executed these commands, the results of the experiments are contained in the folder tests/vldbj2020/results/
. For creating TikZ figures and tables that visualize the results, run the script process_results.py
.
GEDLIB comes with several datassets which contain graphs given in the GXL file format. They are contained in the following subdirectories of the directory data/datasets/
:
AIDS
, Fingerprint
, GREC
, Letter
, Mutagenicity
, Protein
: These datasets are taken from the IAM Graph Database.
You can use them for scientific work, but are requested to include the following reference to your paper:
CMU-GED
: This datasets is taken from the Graph Data Repository for Graph Edit Distance.
You can use it for scientific work, but are requested to include the following reference to your paper:
acyclic
, alkane
, mao
, pah
: These datasets are taken from GREYC's Chemistry Dataset.S-MOL
: Synthetically generated graphs with varying number of node labels whose structure is similar to the structure of pah
graphs.S-MOL-5
: Synthetically generated graphs with 5 node labels whose structure is similar to the structure of pah
graphs. For each dataset, the directory data/collections/
contains an XML file which lists the contained graphs' GXL files along with their classes. These files match the document type definition data/collections/GraphCollection.dtd
and can hence be used as input for ged::GEDEnv::load_gxl_graphs()
. The Python script data/collections/sample.py
can be used to generate samples of the datasets.
After executing install.py
, the directoy <GEDLIB_ROOT>
has the following internal structure:
.
├── CMakeLists.txt --------------- used for building GEDLIB
├── doxyfile.in ------------------ used for creating the documentation
├── LICENSE.md ------------------- a copy of GNU LGPL
├── README.md -------------------- this file
├── install.py ------------------- installs GEDLIB
├── _data
| ├── _datasets ---------------- contains several datasets
| | └── ...
| └── _collections ------------- contains XML files that list the graphs in the datasets
| ├── GraphCollection.dtd -- document type definition for graph collections
| ├── sample.py ------------ generates a sample from a collection file
| └── ...
├── _ext ------------------------- contains external libraries
| └── ...
├── _docs ------------------------ contains documentation if GEDLIB has been installed with option --doc
| └── ...
├── _lib ------------------------- contains shared libraries if GEDLIB has been installed with option --lib
| └── ...
├── _src ------------------------- contains the sources of GEDLIB
| ├── CMakeLists.txt ----------- used for building GEDLIB
| ├── _edit_costs -------------- contains edit costs for several datasets
| | └── ...
| ├── _env --------------------- contains the architecture of GEDLIB
| | ├── ged_env.hpp ---------- include this header in your application
| | └── ...
| ├── _methods ----------------- contains various methods for computing GED
| | └── ...
| └── _util -------------------- contains utility classes and functions used by the GED methods
| └── ...
├── _median ---------------------- contains median graph computation, clustering, and indexing
| ├── CMakeLists.txt ----------- used for building the executables
| ├── _bin --------------------- contains the executables if GEDLIB has been built with option --median
| | └── ...
| ├── _collections ------------- contains graph collections used by the median graph computation
| | └── ...
| ├── _output ------------------ contains the median graphs once the executables have been run
| | └── ...
| ├── _src --------------------- contains the median graphs once the executables have been run
| | └── ...
| └── _tests ------------------- contains tests
| └── ...
└── _tests ----------------------- contains various tests
└── ...