Commit fbb020c3 authored by Fize Jacques's avatar Fize Jacques

Debug WLK and GED

Change README
parent 01d33886
......@@ -11,17 +11,14 @@ Gmatch4py is a library dedicated to graph matching. Graph structure are stored i
## Installation
First, compile the library by running this command:
To install `GMatch4py`, run the following commands:
```
$ python3 setup.py build_ext
$ git clone https://github.com/Jacobe2169/GMatch4py.git
$ cd GMatch4py
$ python3 setup.py install
```
Then, install the compiled module with:
```
$ pip3 install .
```
## Get Started
......@@ -75,8 +72,8 @@ each code is associated with a reference to the original.**
* Debug algorithms with --> (*debug needed*)
* Improve code structure and performance
* Simplify `setup.py`
* Simplify `setup.py` :heavy_check_mark:
* Some algorithms are distance and others are similarity measure. Must change the compare
methods so it can adapt to the user need. For example, maybe the user want to deal with
graph similarity rather than distance between graph.
* Write the documentation
\ No newline at end of file
graph similarity rather than distance between graph.:heavy_check_mark:
* Write the documentation :see_no_evil:
\ No newline at end of file
......@@ -26,9 +26,10 @@ cdef class GraphEditDistance(AbstractGraphEditDistance):
R2 = nx.create_empty_copy(H)
R2.add_edges_from(H.edges(node2,data=True))
return abs(R2.number_of_edges()-intersection(R,R2).number_of_edges())
diff=abs(R2.number_of_edges()-intersection(R,R2).number_of_edges())
return (diff*self.edge_ins)+(diff*self.edge_del)
else:
return self.node_ins+self.node_del
return 0.
cdef double delete_cost(self, int i, int j, nodesG, G):
if i == j:
......
......@@ -17,12 +17,18 @@ import copy
import networkx as nx
import numpy as np
cimport numpy as np
from ..base cimport Base
cdef class WeisfeleirLehmanKernel(Base):
class WeisfeleirLehmanKernel(object):
__type__ = "sim"
@staticmethod
def compare(graph_list,selected,h=2):
cdef int h
def __init__(self,h=2):
Base.__init__(self,0,True)
self.h=h
cpdef np.ndarray compare(self,list graph_list, list selected):
"""Compute the all-pairs kernel values for a list of graphs.
This function can be used to directly compute the kernel
matrix for a list of graphs. The direct computation of the
......@@ -103,7 +109,7 @@ class WeisfeleirLehmanKernel(object):
new_labels = copy.deepcopy(labels) # Can't work without it !!!
while it < h:
while it < self.h:
# create an empty lookup table
label_lookup = {}
label_counter = 0
......
......@@ -9,6 +9,8 @@ except:
print("You don't seem to have Cython installed. Please get a")
print("copy from www.cython.org and install it")
sys.exit(1)
def scandir(dir, files=[]):
for file in os.listdir(dir):
path = os.path.join(dir, file)
......@@ -18,7 +20,6 @@ def scandir(dir, files=[]):
scandir(path, files)
return files
# generate an Extension object from its dotted name
def makeExtension(extName):
extPath = extName.replace(".", os.path.sep)+".pyx"
......@@ -34,12 +35,9 @@ extNames = scandir("gmatch4py")
extensions = cythonize([makeExtension(name) for name in extNames])
setup(
name="Gmatch4py",
name="GMatch4py",
description="A module for graph matching",
packages=["gmatch4py"],
#ext_modules=cythonize([
# Extension("*", ["gmatch4py/*.pyx"],include_dirs=[np.get_include()])
#]),
packages=["gmatch4py","gmatch4py.ged","gmatch4py.kernels"],
ext_modules=extensions,
cmdclass={'build_ext': build_ext},
setup_requires=["numpy","networkx"],
......@@ -47,7 +45,7 @@ setup(
version="0.1"
)
#Clean cpp and compiled file
f=False
f=True
if f:
if os.path.exists("build"):
shutil.rmtree("build")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment