diff --git a/notebooks/py-graph_test.ipynb b/notebooks/py-graph_test.ipynb index 04080e6..96e0d0d 100644 --- a/notebooks/py-graph_test.ipynb +++ b/notebooks/py-graph_test.ipynb @@ -2,1859 +2,64 @@ "cells": [ { "cell_type": "code", - "execution_count": 3, - "metadata": { - "autoscroll": false, - "collapsed": false, - "ein.tags": "worksheet-0", - "slideshow": { - "slide_type": "-" - } - }, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import paths\n", - "\n", - "from ged.GED import ged\n", - "from utils.graphfiles import loadDataset\n", - "from ged.costfunctions import RiesenCostFunction, ConstantCostFunction\n", - "from ged.bipartiteGED import computeBipartiteCostMatrix, getOptimalMapping" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "autoscroll": false, - "collapsed": false, - "ein.tags": "worksheet-0", - "slideshow": { - "slide_type": "-" - } - }, - "outputs": [], - "source": [ - "import networkx as nx\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "\n", - "# We load a ds dataset\n", - "dataset, y = loadDataset(\"/home/bgauzere/work/Datasets/Acyclic/dataset_bps.ds\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "autoscroll": false, - "collapsed": false, - "ein.tags": "worksheet-0", - "slideshow": { - "slide_type": "-" - } - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\r", - " 0%| | 0/183 [00:00= 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 diff --git a/pygraph/ged/bipartiteGED.py b/pygraph/ged/bipartiteGED.py index ab3aadf..b997f9e 100644 --- a/pygraph/ged/bipartiteGED.py +++ b/pygraph/ged/bipartiteGED.py @@ -1,6 +1,6 @@ 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