Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fize Jacques
GMatch4py
Commits
970852f0
Commit
970852f0
authored
Jul 11, 2018
by
Fize Jacques
Browse files
Patch BOC
DEBUG Linux setup
parent
b970b0e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
gmatch4py/bag_of_cliques.pyx
View file @
970852f0
...
...
@@ -43,9 +43,11 @@ def nx2nk(nxG, weightAttr=None):
def
getClique
(
nx_graph
):
final_cliques
=
[]
if
len
(
nx_graph
)
==
0
:
if
len
(
nx_graph
)
==
0
or
not
nx_graph
:
return
final_cliques
netkit_graph
,
idmap
=
nx2nk
(
nx_graph
)
if
not
netkit_graph
:
return
final_cliques
idmap
=
{
v
:
k
for
k
,
v
in
idmap
.
items
()}
cliques
=
MaximalCliques
(
netkit_graph
).
run
().
getCliques
()
for
cl
in
cliques
:
...
...
@@ -63,8 +65,9 @@ class BagOfCliques():
cdef
double
[:,:]
scores
=
np
.
zeros
((
n
,
n
))
cdef
int
i
for
i
in
range
(
len
(
scores
)):
if
not
i
in
selected
:
continue
if
selected
:
if
not
i
in
selected
:
continue
for
j
in
range
(
i
,
len
(
scores
)):
scores
[
i
,
j
]
=
(
np
.
dot
(
bog
[
i
],
bog
[
j
]))
/
(
np
.
sqrt
(
np
.
sum
(
bog
[
i
]
**
2
))
*
np
.
sqrt
(
np
.
sum
(
bog
[
j
]
**
2
)))
# Can be computed in one line
scores
[
j
,
i
]
=
scores
[
i
,
j
]
...
...
@@ -163,4 +166,9 @@ class BagOfCliques():
if
hash
in
map_str_cliques
:
vector
[
map_str_cliques
[
hash
]]
=
1
boc
[
g
]
=
vector
return
boc
\ No newline at end of file
return
boc
def
distance
(
self
,
matrix
):
return
1
-
np
.
array
(
matrix
)
def
similarity
(
self
,
matrix
):
return
np
.
array
(
matrix
)
\ No newline at end of file
setup.py
View file @
970852f0
...
...
@@ -10,6 +10,10 @@ except:
print
(
"copy from www.cython.org and install it"
)
sys
.
exit
(
1
)
is_linux
=
sys
.
platform
.
system
()
==
'Linux'
libs
=
[]
if
is_linux
:
# Issue #42
libs
.
append
(
'rt'
)
# -lrt for clock_gettime
def
scandir
(
dir
,
files
=
[]):
for
file
in
os
.
listdir
(
dir
):
...
...
@@ -22,18 +26,24 @@ def scandir(dir, files=[]):
# generate an Extension object from its dotted name
def
makeExtension
(
extName
):
global
libs
extPath
=
extName
.
replace
(
"."
,
os
.
path
.
sep
)
+
".pyx"
return
Extension
(
extName
,
[
extPath
],
include_dirs
=
[
np
.
get_include
()],
language
=
'c++'
[
extPath
],
include_dirs
=
[
np
.
get_include
()],
language
=
'c++'
,
libraries
=
libs
)
# get the list of extensions
extNames
=
scandir
(
"gmatch4py"
)
# and build up the set of Extension objects
extensions
=
cythonize
([
makeExtension
(
name
)
for
name
in
extNames
])
setup
(
name
=
"GMatch4py"
,
description
=
"A module for graph matching"
,
...
...
@@ -45,7 +55,7 @@ setup(
version
=
"0.1"
)
#Clean cpp and compiled file
f
=
Tru
e
f
=
Fals
e
if
f
:
if
os
.
path
.
exists
(
"build"
):
shutil
.
rmtree
(
"build"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment