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
5fd961a9
Commit
5fd961a9
authored
Sep 25, 2018
by
Fize Jacques
Browse files
Add Weight integration in the GraphEditDistance Algorithm
Add scikit-learn in the dependencies
parent
ebef6145
Changes
3
Hide whitespace changes
Inline
Side-by-side
gmatch4py/ged/abstract_graph_edit_dist.pxd
View file @
5fd961a9
...
...
@@ -8,6 +8,7 @@ cdef class AbstractGraphEditDistance(Base):
cdef
double
edge_del
cdef
double
edge_ins
cdef
np
.
ndarray
cost_matrix
cdef
bint
weighted
cpdef
double
distance_ged
(
self
,
G
,
H
)
cdef
list
edit_costs
(
self
,
G
,
H
)
...
...
gmatch4py/ged/graph_edit_dist.pyx
View file @
5fd961a9
...
...
@@ -11,9 +11,9 @@ from ..base cimport intersection,union_
cdef
class
GraphEditDistance
(
AbstractGraphEditDistance
):
def
__init__
(
self
,
node_del
,
node_ins
,
edge_del
,
edge_ins
):
def
__init__
(
self
,
node_del
,
node_ins
,
edge_del
,
edge_ins
,
weighted
=
False
):
AbstractGraphEditDistance
.
__init__
(
self
,
node_del
,
node_ins
,
edge_del
,
edge_ins
)
self
.
weighted
=
weighted
cpdef
double
substitute_cost
(
self
,
node1
,
node2
,
G
,
H
):
return
self
.
relabel_cost
(
node1
,
node2
,
G
,
H
)
...
...
@@ -54,12 +54,12 @@ cdef class GraphEditDistance(AbstractGraphEditDistance):
cdef
double
delete_cost
(
self
,
int
i
,
int
j
,
nodesG
,
G
):
if
i
==
j
:
return
self
.
node_del
+
(
G
.
degree
(
nodesG
[
i
])
*
self
.
edge_del
)
# Deleting a node implicate to delete in and out edges
return
self
.
node_del
+
(
G
.
degree
(
nodesG
[
i
]
,
weight
=
(
"weight"
if
self
.
weighted
else
None
)
)
*
self
.
edge_del
)
# Deleting a node implicate to delete in and out edges
return
sys
.
maxsize
cdef
double
insert_cost
(
self
,
int
i
,
int
j
,
nodesH
,
H
):
if
i
==
j
:
deg
=
H
.
degree
(
nodesH
[
j
])
deg
=
H
.
degree
(
nodesH
[
j
]
,
weight
=
(
"weight"
if
self
.
weighted
else
None
)
)
if
isinstance
(
deg
,
dict
):
deg
=
0
return
self
.
node_ins
+
(
deg
*
self
.
edge_ins
)
else
:
...
...
setup.py
View file @
5fd961a9
...
...
@@ -55,8 +55,8 @@ setup(
packages
=
[
"gmatch4py"
,
"gmatch4py.helpers"
],
ext_modules
=
extensions
,
cmdclass
=
{
'build_ext'
:
build_ext
},
setup_requires
=
[
"numpy"
,
"networkx"
,
"scipy"
],
install_requires
=
[
"numpy"
,
"networkx"
,
"scipy"
],
setup_requires
=
[
"numpy"
,
"networkx"
,
"scipy"
,
'scikit-learn'
],
install_requires
=
[
"numpy"
,
"networkx"
,
"scipy"
,
'scikit-learn'
],
version
=
"0.2.2"
,
classifiers
=
[
"Programming Language :: Python :: 3"
,
...
...
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