diff --git a/.gitignore b/.gitignore index a2469c64438bf31d1f42df2e6bc53447b0819cef..52ac436539b4096f216358ab61cc931fc835bd35 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,5 @@ venv.bak/ *.cpp *.c .DS_Store -.idea \ No newline at end of file +.idea +.vscode \ No newline at end of file diff --git a/README.md b/README.md index 260f0dd36d8f385c5de5695c32c246fa72bc17ab..255a1091475e0de3d8fa55f4b92de23260f42b46 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,11 @@ GMatch4py algorithms were implemented with Cython to enhance performance. To install `GMatch4py`, run the following commands: +```bash +git clone https://github.com/Jacobe2169/GMatch4py.git +cd GMatch4py +(sudo) python3 setup.py install ``` -$ git clone https://github.com/Jacobe2169/GMatch4py.git -$ cd GMatch4py -$ (sudo) python3 setup.py install -``` - ## Get Started ### Graph input format @@ -31,7 +30,7 @@ comes with a large spectrum of parser to load your graph from various inputs : ` ### Use Gmatch4py If you want to use algorithms like *graph edit distances*, here is an example: -```{python} +```python # Gmatch4py use networkx graph import networkx as nx # import the GED using the munkres algorithm @@ -39,7 +38,7 @@ import gmatch4py as gm ``` In this example, we use generated graphs using `networkx` helpers: -```{python} +```python g1=nx.complete_bipartite_graph(5,4) g2=nx.complete_bipartite_graph(6,4) ``` @@ -48,21 +47,21 @@ All graph matching algorithms in `Gmatch4py work this way: * Each algorithm is associated with an object, each object having its specific parameters. In this case, the parameters are the edit costs (delete a vertex, add a vertex, ...) * Each object is associated with a `compare()` function with two parameters. First parameter is **a list of the graphs** you want to **compare**, i.e. measure the distance/similarity (depends on the algorithm). Then, you can specify a sample of graphs to be compared to all the other graphs. To this end, the second parameter should be **a list containing the indices** of these graphs (based on the first parameter list). If you rather compute the distance/similarity **between all graphs**, just use the `None` value. -```{python} +```python ged=gm.GraphEditDistance(1,1,1,1) # all edit costs are equal to 1 result=ged.compare([g1,g2],None) print(result) ``` The output is a similarity/distance matrix : -``` +```python Out[10]: array([[0., 14.], [10., 0.]]) ``` This output result is "raw", if you wish to have normalized results in terms of distance (or similarity) you can use : -``` +```python ged.similarity(result) # or ged.distance(result) diff --git a/setup.py b/setup.py index c3e46f9d49c0e0695a1ad4130895095794277c2c..b2fc383c619d2d2612e9fbe7c3084e6848e07871 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import sys, os, shutil from distutils.core import setup from distutils.extension import Extension import numpy as np +import platform try: from Cython.Build import cythonize from Cython.Distutils import build_ext @@ -29,6 +30,16 @@ def scandir(dir, files=[]): def makeExtension(extName): global libs extPath = extName.replace(".", os.path.sep)+".pyx" + + ## For Mojave Users + if platform.system() == "Darwin": + if "10.14" in platform.mac_ver()[0]: + return Extension( + extName, + [extPath],include_dirs=[np.get_include()],language='c++',libraries=libs, + extra_compile_args=["-stdlib=libc++"] + ) + return Extension( extName, [extPath],include_dirs=[np.get_include()],language='c++',libraries=libs