-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.py
44 lines (30 loc) · 1.09 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
main.py
Distance computation and comparison between different aproximated graph edit distance techniques with the same costs.
"""
from VanillaAED import VanillaAED
from VanillaHED import VanillaHED
import os
import glob
import itertools
import networkx as nx
__author__ = "Pau Riba, Anjan Dutta"
__email__ = "[email protected], [email protected]"
if __name__ == '__main__':
path_dataset = './data/'
name_dataset = 'Letters'
aed = VanillaAED()
hed = VanillaHED()
path_dataset = os.path.join(path_dataset, name_dataset)
files = glob.glob(path_dataset + '/*.gml')
for f1, f2 in itertools.combinations_with_replacement(files, 2):
# Read graphs
g1 = nx.read_gml(f1)
g2 = nx.read_gml(f2)
# Distance AED
distAED, _ = aed.ged(g1, g2)
# Distance HED
distHED, _ = hed.ged(g1, g2)
print(g1.graph['class'] + ' <-> ' + g2.graph['class'] + ' | HED: ' + str(distHED) + ' AED: ' + str(distAED) + ' | ' + str(distHED<=distAED) + (' Exact GED ' if distHED==distAED else ''))