Commit fbb72662 authored by Benoit GAUZERE's avatar Benoit GAUZERE

change np.inf to sys.maxsize to avoid non numeric values

parent bfc6e766
import numpy as np import numpy as np
from scipy.optimize import linear_sum_assignment from scipy.optimize import linear_sum_assignment
from pygraph.ged.costfunctions import ConstantCostFunction from pygraph.ged.costfunctions import ConstantCostFunction
import sys
def computeBipartiteCostMatrix(G1, G2, cf=ConstantCostFunction(1, 3, 1, 3)): def computeBipartiteCostMatrix(G1, G2, cf=ConstantCostFunction(1, 3, 1, 3)):
"""Compute a Cost Matrix according to cost function cf""" """Compute a Cost Matrix according to cost function cf"""
n = G1.number_of_nodes() n = G1.number_of_nodes()
m = G2.number_of_nodes() m = G2.number_of_nodes()
nm = n + m nm = n + m
C = np.ones([nm, nm])*np.inf C = np.ones([nm, nm])*sys.maxsize
C[n:, m:] = 0 C[n:, m:] = 0
for u in G1.nodes(): for u in G1.nodes():
......
import numpy as np import numpy as np
from scipy.optimize import linear_sum_assignment from scipy.optimize import linear_sum_assignment
import sys
class ConstantCostFunction: class ConstantCostFunction:
""" Define a symmetric constant cost fonction for edit operations """ """ Define a symmetric constant cost fonction for edit operations """
...@@ -54,7 +54,7 @@ class RiesenCostFunction(): ...@@ -54,7 +54,7 @@ class RiesenCostFunction():
""" u et v sont des id de noeuds """ """ u et v sont des id de noeuds """
n = len(G1[u]) n = len(G1[u])
m = len(G2[v]) m = len(G2[v])
sub_C = np.ones([n+m, n+m]) * np.inf sub_C = np.ones([n+m, n+m]) * sys.maxsize
sub_C[n:, m:] = 0 sub_C[n:, m:] = 0
i = 0 i = 0
l_nbr_u = G1[u] l_nbr_u = G1[u]
...@@ -105,7 +105,7 @@ class NeighboorhoodCostFunction(): ...@@ -105,7 +105,7 @@ class NeighboorhoodCostFunction():
""" u et v sont des id de noeuds """ """ u et v sont des id de noeuds """
n = len(G1[u]) n = len(G1[u])
m = len(G2[v]) m = len(G2[v])
sub_C = np.ones([n+m, n+m]) * np.inf sub_C = np.ones([n+m, n+m]) * sys.maxsize
sub_C[n:, m:] = 0 sub_C[n:, m:] = 0
i = 0 i = 0
l_nbr_u = G1[u] l_nbr_u = G1[u]
......
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