Commit 66129a66 authored by Benoit GAUZERE's avatar Benoit GAUZERE

Update to NetworkX 2.0

parent 595e09c6
This diff is collapsed.
from ged.costfunctions import ConstantCostFunction, RiesenCostFunction
from ged.costfunctions import NeighboorhoodCostFunction
from ged.bipartiteGED import computeBipartiteCostMatrix, getOptimalMapping
from pygraph.ged.costfunctions import ConstantCostFunction, RiesenCostFunction
from pygraph.ged.costfunctions import NeighboorhoodCostFunction
from pygraph.ged.bipartiteGED import computeBipartiteCostMatrix, getOptimalMapping
from scipy.optimize import linear_sum_assignment
def ged(G1, G2, method='Riesen', rho=None, varrho=None,
......@@ -29,18 +29,18 @@ def ged(G1, G2, method='Riesen', rho=None, varrho=None,
n = G1.number_of_nodes()
m = G2.number_of_nodes()
ged = 0
for i in G1.nodes_iter():
for i in G1.nodes():
phi_i = rho[i]
if(phi_i >= m):
ged += cf.cnd(i, G1)
else:
ged += cf.cns(i, phi_i, G1, G2)
for j in G2.nodes_iter():
for j in G2.nodes():
phi_j = varrho[j]
if(phi_j >= n):
ged += cf.cni(j, G2)
for e in G1.edges_iter(data=True):
for e in G1.edges(data=True):
i = e[0]
j = e[1]
phi_i = rho[i]
......@@ -57,7 +57,7 @@ def ged(G1, G2, method='Riesen', rho=None, varrho=None,
ged += cf.ced(e, G1)
else:
ged += cf.ced(e, G1)
for e in G2.edges_iter(data=True):
for e in G2.edges(data=True):
i = e[0]
j = e[1]
phi_i = varrho[i]
......@@ -70,7 +70,3 @@ def ged(G1, G2, method='Riesen', rho=None, varrho=None,
else:
ged += cf.ced(e, G2)
return ged, rho, varrho
def computeDistanceMatrix(dataset):
pass
import numpy as np
from scipy.optimize import linear_sum_assignment
from ged.costfunctions import ConstantCostFunction
from pygraph.ged.costfunctions import ConstantCostFunction
def computeBipartiteCostMatrix(G1, G2, cf=ConstantCostFunction(1, 3, 1, 3)):
......@@ -11,15 +11,15 @@ def computeBipartiteCostMatrix(G1, G2, cf=ConstantCostFunction(1, 3, 1, 3)):
C = np.ones([nm, nm])*np.inf
C[n:, m:] = 0
for u in G1.nodes_iter():
for v in G2.nodes_iter():
for u in G1.nodes():
for v in G2.nodes():
cost = cf.cns(u, v, G1, G2)
C[u, v] = cost
for v in G1.nodes_iter():
for v in G1.nodes():
C[v, m + v] = cf.cnd(v, G1)
for v in G2.nodes_iter():
for v in G2.nodes():
C[n + v, v] = cf.cni(v, G2)
return C
......
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