Giter Site home page Giter Site logo

weathon / gedlibpy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryurin/gedlibpy

0.0 0.0 0.0 164.89 MB

The binding of GedLib (C++ library) on Python (Newest Version)

Shell 0.15% JavaScript 0.42% Ruby 0.01% C++ 95.72% Python 0.85% Perl 0.02% C 1.66% PHP 0.03% Objective-C 0.01% Java 0.13% Eiffel 0.01% Fortran 0.54% Tcl 0.01% D 0.01% C# 0.02% Assembly 0.13% MATLAB 0.05% Rebol 0.01% Max 0.01% XSLT 0.27%

gedlibpy's Introduction

GEDLIBPY

Please Read https://dbblumenthal.github.io/gedlib/ before using Python code. You can also find this module documentation in documentation/build/html folder.

Make sure you have numpy installed (and Cython if you have to recompile the library). You can use pip for this.

Running the script

After donwloading the entire folder, you can run test.py to ensure the library works.

For your code, you have to make two imports:

import librariesImport
import gedlibpy

You can call each function in the library with this. You can't move any folder or files on the library, please make sure that the architecture remains the same.

This library is compiled for Python3 only. If you want to use it with Python 2, you have to recompile it with setup.py. You have to use this command on your favorite shell:

python setup.py build_ext --inplace

After this step, you can use the same lines as Python3 for import, it will be ok. Check the documentation inside the documentation/build/html folder before using function. You can also copy the tests examples for basic use.

A problem with the library ?

If the library isn't found, you can recompile the Python library because your Linux is different to mine. Please delete gedlibpy.so, gedlibpy.cpp and build folder. Then use this command on a linux shell

python3 setup.py build_ext --inplace

You can make it with Python 2 but make sure you use the same version with your code and the compilation.

If it's doesn't work, maybe the version of GedLib or another library can be a problem. If it is, you can re-install GedLib for your computer. You can download it on this git : https://dbblumenthal.github.io/gedlib/

You have to install Gedlib with the Python installer after that. Just call:

python3 install.py

Make the links like indicate on the documentation. Use the same architecture like this library, but just change the .so and folders with your installation. You can recompile the Python library with setup command, after that.

If you use Mac OS, you have to follow all this part, and install the external libraries with this command:

install_name_tool -change <mylib> <path>/<to>/<mylib> <myexec>

For an example, you have to write these lines:

install_name_tool -change libdoublefann.2.dylib lib/fann/libdoublefann.2.dylib gedlibpy.so
install_name_tool -change libsvm.so lib/libsvm.3.22/libsvm.so gedlibpy.so
install_name_tool -change libnomad.so lib/nomad/libnomad.so gedlibpy.so
install_name_tool -change libsgtelib.so lib/nomad/libsgtelib.so gedlibpy.so

The name of the library gedlibpy can be different if you use Python 3.

If your problem is still here, you can contact me on : [email protected]

How to use this library

This library allow to compute edit distance between two graphs. You have to follow these steps to use it :

  • Add your graphs (GXL files, NX Structures or your structure, make sure that the internal type is the same)
  • Choose your cost function
  • Init your environnment (After that, the cost function and your graphs can't be modified)
  • Choose your method computation
  • Run the computation with the IDs of the two graphs. You can have the ID when you add the graph or with some functions
  • Find the result with differents functions (NodeMap, edit distance, etc)

Here is an example of code with GXL graphs:

gedlibpy.load_GXL_graphs('include/gedlib-master/data/datasets/Mutagenicity/data/', 'collections/MUTA_10.xml')
listID = gedlibpy.get_all_graph_ids()
gedlibpy.set_edit_cost("CHEM_1")
gedlibpy.init()
gedlibpy.set_method("IPFP", "")
gedlibpy.init_method()
g = listID[0]
h = listID[1]

gedlibpy.run_method(g,h)

print("Node Map : ", gedlibpy.get_node_map(g,h))
print ("Upper Bound = " + str(gedlibpy.get_upper_bound(g,h)) + ", Lower Bound = " + str(gedlibpy.get_lower_bound(g,h)) + ", Runtime = " + str(gedlibpy.get_runtime(g,h)))

Please read the documentation for more examples and functions.

An advice if you don't code in a shell

Python library don't indicate each C++ error. If you have a restart causing by an error in your code, please use on a linux shell for having C++ errors.

gedlibpy's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.