Commit 4cea92b0 authored by Fize Jacques's avatar Fize Jacques

Add MacOS mojave compatibility. Change Readme

parent 217393df
...@@ -105,4 +105,5 @@ venv.bak/ ...@@ -105,4 +105,5 @@ venv.bak/
*.cpp *.cpp
*.c *.c
.DS_Store .DS_Store
.idea .idea
\ No newline at end of file .vscode
\ No newline at end of file
...@@ -15,12 +15,11 @@ GMatch4py algorithms were implemented with Cython to enhance performance. ...@@ -15,12 +15,11 @@ GMatch4py algorithms were implemented with Cython to enhance performance.
To install `GMatch4py`, run the following commands: 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 ## Get Started
### Graph input format ### Graph input format
...@@ -31,7 +30,7 @@ comes with a large spectrum of parser to load your graph from various inputs : ` ...@@ -31,7 +30,7 @@ comes with a large spectrum of parser to load your graph from various inputs : `
### Use Gmatch4py ### Use Gmatch4py
If you want to use algorithms like *graph edit distances*, here is an example: If you want to use algorithms like *graph edit distances*, here is an example:
```{python} ```python
# Gmatch4py use networkx graph # Gmatch4py use networkx graph
import networkx as nx import networkx as nx
# import the GED using the munkres algorithm # import the GED using the munkres algorithm
...@@ -39,7 +38,7 @@ import gmatch4py as gm ...@@ -39,7 +38,7 @@ import gmatch4py as gm
``` ```
In this example, we use generated graphs using `networkx` helpers: In this example, we use generated graphs using `networkx` helpers:
```{python} ```python
g1=nx.complete_bipartite_graph(5,4) g1=nx.complete_bipartite_graph(5,4)
g2=nx.complete_bipartite_graph(6,4) g2=nx.complete_bipartite_graph(6,4)
``` ```
...@@ -48,21 +47,21 @@ All graph matching algorithms in `Gmatch4py work this way: ...@@ -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 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. * 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 ged=gm.GraphEditDistance(1,1,1,1) # all edit costs are equal to 1
result=ged.compare([g1,g2],None) result=ged.compare([g1,g2],None)
print(result) print(result)
``` ```
The output is a similarity/distance matrix : The output is a similarity/distance matrix :
``` ```python
Out[10]: Out[10]:
array([[0., 14.], array([[0., 14.],
[10., 0.]]) [10., 0.]])
``` ```
This output result is "raw", if you wish to have normalized results in terms of distance (or similarity) you can use : 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) ged.similarity(result)
# or # or
ged.distance(result) ged.distance(result)
......
...@@ -3,6 +3,7 @@ import sys, os, shutil ...@@ -3,6 +3,7 @@ import sys, os, shutil
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
import numpy as np import numpy as np
import platform
try: try:
from Cython.Build import cythonize from Cython.Build import cythonize
from Cython.Distutils import build_ext from Cython.Distutils import build_ext
...@@ -29,6 +30,16 @@ def scandir(dir, files=[]): ...@@ -29,6 +30,16 @@ def scandir(dir, files=[]):
def makeExtension(extName): def makeExtension(extName):
global libs global libs
extPath = extName.replace(".", os.path.sep)+".pyx" 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( return Extension(
extName, extName,
[extPath],include_dirs=[np.get_include()],language='c++',libraries=libs [extPath],include_dirs=[np.get_include()],language='c++',libraries=libs
......
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