You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

untilHPathKernel.py 23 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. """
  2. @author: linlin
  3. @references: Liva Ralaivola, Sanjay J Swamidass, Hiroto Saigo, and Pierre
  4. Baldi. Graph kernels for chemical informatics. Neural networks,
  5. 18(8):1093–1110, 2005.
  6. """
  7. import sys
  8. sys.path.insert(0, "../")
  9. import time
  10. from collections import Counter
  11. from itertools import chain
  12. from functools import partial
  13. from multiprocessing import Pool
  14. from tqdm import tqdm
  15. import networkx as nx
  16. import numpy as np
  17. from pygraph.utils.graphdataset import get_dataset_attributes
  18. from pygraph.utils.parallel import parallel_gm
  19. from pygraph.utils.trie import Trie
  20. def untilhpathkernel(*args,
  21. node_label='atom',
  22. edge_label='bond_type',
  23. depth=10,
  24. k_func='tanimoto',
  25. compute_method='trie',
  26. n_jobs=None,
  27. verbose=True):
  28. """Calculate path graph kernels up to depth/hight h between graphs.
  29. Parameters
  30. ----------
  31. Gn : List of NetworkX graph
  32. List of graphs between which the kernels are calculated.
  33. /
  34. G1, G2 : NetworkX graphs
  35. 2 graphs between which the kernel is calculated.
  36. node_label : string
  37. Node attribute used as label. The default node label is atom.
  38. edge_label : string
  39. Edge attribute used as label. The default edge label is bond_type.
  40. depth : integer
  41. Depth of search. Longest length of paths.
  42. k_func : function
  43. A kernel function applied using different notions of fingerprint
  44. similarity.
  45. compute_method: string
  46. Computation method, 'trie' or 'naive'.
  47. Return
  48. ------
  49. Kmatrix : Numpy matrix
  50. Kernel matrix, each element of which is the path kernel up to h between
  51. 2 praphs.
  52. """
  53. # pre-process
  54. depth = int(depth)
  55. Gn = args[0] if len(args) == 1 else [args[0], args[1]]
  56. Kmatrix = np.zeros((len(Gn), len(Gn)))
  57. ds_attrs = get_dataset_attributes(
  58. Gn,
  59. attr_names=['node_labeled', 'edge_labeled', 'is_directed'],
  60. node_label=node_label, edge_label=edge_label)
  61. if not ds_attrs['node_labeled']:
  62. for G in Gn:
  63. nx.set_node_attributes(G, '0', 'atom')
  64. if not ds_attrs['edge_labeled']:
  65. for G in Gn:
  66. nx.set_edge_attributes(G, '0', 'bond_type')
  67. start_time = time.time()
  68. # ---- use pool.imap_unordered to parallel and track progress. ----
  69. # get all paths of all graphs before calculating kernels to save time,
  70. # but this may cost a lot of memory for large datasets.
  71. pool = Pool(n_jobs)
  72. itr = zip(Gn, range(0, len(Gn)))
  73. if len(Gn) < 100 * n_jobs:
  74. chunksize = int(len(Gn) / n_jobs) + 1
  75. else:
  76. chunksize = 100
  77. all_paths = [[] for _ in range(len(Gn))]
  78. if compute_method == 'trie':
  79. getps_partial = partial(wrapper_find_all_path_as_trie, depth,
  80. ds_attrs, node_label, edge_label)
  81. else:
  82. getps_partial = partial(wrapper_find_all_paths_until_length, depth,
  83. ds_attrs, node_label, edge_label)
  84. if verbose:
  85. iterator = tqdm(pool.imap_unordered(getps_partial, itr, chunksize),
  86. desc='getting paths', file=sys.stdout)
  87. else:
  88. iterator = pool.imap_unordered(getps_partial, itr, chunksize)
  89. for i, ps in iterator:
  90. all_paths[i] = ps
  91. pool.close()
  92. pool.join()
  93. # for g in Gn:
  94. # if compute_method == 'trie':
  95. # find_all_path_as_trie(g, depth, ds_attrs, node_label, edge_label)
  96. # else:
  97. # find_all_paths_until_length(g, depth, ds_attrs, node_label, edge_label)
  98. ## size = sys.getsizeof(all_paths)
  99. ## for item in all_paths:
  100. ## size += sys.getsizeof(item)
  101. ## for pppps in item:
  102. ## size += sys.getsizeof(pppps)
  103. ## print(size)
  104. #
  105. ## ttt = time.time()
  106. ## # ---- ---- use pool.map to parallel ----
  107. ## for i, ps in tqdm(
  108. ## pool.map(getps_partial, range(0, len(Gn))),
  109. ## desc='getting paths', file=sys.stdout):
  110. ## all_paths[i] = ps
  111. ## print(time.time() - ttt)
  112. if compute_method == 'trie':
  113. def init_worker(trie_toshare):
  114. global G_trie
  115. G_trie = trie_toshare
  116. do_partial = partial(wrapper_uhpath_do_trie, k_func)
  117. parallel_gm(do_partial, Kmatrix, Gn, init_worker=init_worker,
  118. glbv=(all_paths,), n_jobs=n_jobs, verbose=verbose)
  119. else:
  120. def init_worker(plist_toshare):
  121. global G_plist
  122. G_plist = plist_toshare
  123. do_partial = partial(wrapper_uhpath_do_naive, k_func)
  124. parallel_gm(do_partial, Kmatrix, Gn, init_worker=init_worker,
  125. glbv=(all_paths,), n_jobs=n_jobs, verbose=verbose)
  126. # # ---- direct running, normally use single CPU core. ----
  127. # all_paths = [
  128. # find_all_paths_until_length(
  129. # Gn[i],
  130. # depth,
  131. # ds_attrs,
  132. # node_label=node_label,
  133. # edge_label=edge_label) for i in tqdm(
  134. # range(0, len(Gn)), desc='getting paths', file=sys.stdout)
  135. # ]
  136. #
  137. # if compute_method == 'trie':
  138. # pbar = tqdm(
  139. # total=((len(Gn) + 1) * len(Gn) / 2),
  140. # desc='calculating kernels',
  141. # file=sys.stdout)
  142. # for i in range(0, len(Gn)):
  143. # for j in range(i, len(Gn)):
  144. # Kmatrix[i][j] = _untilhpathkernel_do_trie(all_paths[i],
  145. # all_paths[j], k_func)
  146. # Kmatrix[j][i] = Kmatrix[i][j]
  147. # pbar.update(1)
  148. # else:
  149. # pbar = tqdm(
  150. # total=((len(Gn) + 1) * len(Gn) / 2),
  151. # desc='calculating kernels',
  152. # file=sys.stdout)
  153. # for i in range(0, len(Gn)):
  154. # for j in range(i, len(Gn)):
  155. # Kmatrix[i][j] = _untilhpathkernel_do_naive(all_paths[i], all_paths[j],
  156. # k_func)
  157. # Kmatrix[j][i] = Kmatrix[i][j]
  158. # pbar.update(1)
  159. run_time = time.time() - start_time
  160. if verbose:
  161. print("\n --- kernel matrix of path kernel up to %d of size %d built in %s seconds ---"
  162. % (depth, len(Gn), run_time))
  163. # print(Kmatrix[0][0:10])
  164. return Kmatrix, run_time
  165. def _untilhpathkernel_do_trie(trie1, trie2, k_func):
  166. """Calculate path graph kernels up to depth d between 2 graphs using trie.
  167. Parameters
  168. ----------
  169. trie1, trie2 : list
  170. Tries that contains all paths in 2 graphs.
  171. k_func : function
  172. A kernel function applied using different notions of fingerprint
  173. similarity.
  174. Return
  175. ------
  176. kernel : float
  177. Path kernel up to h between 2 graphs.
  178. """
  179. if k_func == 'tanimoto':
  180. # traverse all paths in graph1 and search them in graph2. Deep-first
  181. # search is applied.
  182. def traverseTrie1t(root, trie2, setlist, pcurrent=[]):
  183. for key, node in root['children'].items():
  184. pcurrent.append(key)
  185. if node['isEndOfWord']:
  186. setlist[1] += 1
  187. count2 = trie2.searchWord(pcurrent)
  188. if count2 != 0:
  189. setlist[0] += 1
  190. if node['children'] != {}:
  191. traverseTrie1t(node, trie2, setlist, pcurrent)
  192. else:
  193. del pcurrent[-1]
  194. if pcurrent != []:
  195. del pcurrent[-1]
  196. # traverse all paths in graph2 and find out those that are not in
  197. # graph1. Deep-first search is applied.
  198. def traverseTrie2t(root, trie1, setlist, pcurrent=[]):
  199. for key, node in root['children'].items():
  200. pcurrent.append(key)
  201. if node['isEndOfWord']:
  202. # print(node['count'])
  203. count1 = trie1.searchWord(pcurrent)
  204. if count1 == 0:
  205. setlist[1] += 1
  206. if node['children'] != {}:
  207. traverseTrie2t(node, trie1, setlist, pcurrent)
  208. else:
  209. del pcurrent[-1]
  210. if pcurrent != []:
  211. del pcurrent[-1]
  212. setlist = [0, 0] # intersection and union of path sets of g1, g2.
  213. # print(trie1.root)
  214. # print(trie2.root)
  215. traverseTrie1t(trie1.root, trie2, setlist)
  216. # print(setlist)
  217. traverseTrie2t(trie2.root, trie1, setlist)
  218. # print(setlist)
  219. kernel = setlist[0] / setlist[1]
  220. else: # MinMax kernel
  221. # traverse all paths in graph1 and search them in graph2. Deep-first
  222. # search is applied.
  223. def traverseTrie1m(root, trie2, sumlist, pcurrent=[]):
  224. for key, node in root['children'].items():
  225. pcurrent.append(key)
  226. if node['isEndOfWord']:
  227. # print(node['count'])
  228. count1 = node['count']
  229. count2 = trie2.searchWord(pcurrent)
  230. sumlist[0] += min(count1, count2)
  231. sumlist[1] += max(count1, count2)
  232. if node['children'] != {}:
  233. traverseTrie1m(node, trie2, sumlist, pcurrent)
  234. else:
  235. del pcurrent[-1]
  236. if pcurrent != []:
  237. del pcurrent[-1]
  238. # traverse all paths in graph2 and find out those that are not in
  239. # graph1. Deep-first search is applied.
  240. def traverseTrie2m(root, trie1, sumlist, pcurrent=[]):
  241. for key, node in root['children'].items():
  242. pcurrent.append(key)
  243. if node['isEndOfWord']:
  244. # print(node['count'])
  245. count1 = trie1.searchWord(pcurrent)
  246. if count1 == 0:
  247. sumlist[1] += node['count']
  248. if node['children'] != {}:
  249. traverseTrie2m(node, trie1, sumlist, pcurrent)
  250. else:
  251. del pcurrent[-1]
  252. if pcurrent != []:
  253. del pcurrent[-1]
  254. sumlist = [0, 0] # sum of mins and sum of maxs
  255. # print(trie1.root)
  256. # print(trie2.root)
  257. traverseTrie1m(trie1.root, trie2, sumlist)
  258. # print(sumlist)
  259. traverseTrie2m(trie2.root, trie1, sumlist)
  260. # print(sumlist)
  261. kernel = sumlist[0] / sumlist[1]
  262. return kernel
  263. def wrapper_uhpath_do_trie(k_func, itr):
  264. i = itr[0]
  265. j = itr[1]
  266. return i, j, _untilhpathkernel_do_trie(G_trie[i], G_trie[j], k_func)
  267. def _untilhpathkernel_do_naive(paths1, paths2, k_func):
  268. """Calculate path graph kernels up to depth d between 2 graphs naively.
  269. Parameters
  270. ----------
  271. paths_list : list of list
  272. List of list of paths in all graphs, where for unlabeled graphs, each
  273. path is represented by a list of nodes; while for labeled graphs, each
  274. path is represented by a string consists of labels of nodes and/or
  275. edges on that path.
  276. k_func : function
  277. A kernel function applied using different notions of fingerprint
  278. similarity.
  279. Return
  280. ------
  281. kernel : float
  282. Path kernel up to h between 2 graphs.
  283. """
  284. all_paths = list(set(paths1 + paths2))
  285. if k_func == 'tanimoto':
  286. length_union = len(set(paths1 + paths2))
  287. kernel = (len(set(paths1)) + len(set(paths2)) -
  288. length_union) / length_union
  289. # vector1 = [(1 if path in paths1 else 0) for path in all_paths]
  290. # vector2 = [(1 if path in paths2 else 0) for path in all_paths]
  291. # kernel_uv = np.dot(vector1, vector2)
  292. # kernel = kernel_uv / (len(set(paths1)) + len(set(paths2)) - kernel_uv)
  293. else: # MinMax kernel
  294. path_count1 = Counter(paths1)
  295. path_count2 = Counter(paths2)
  296. vector1 = [(path_count1[key] if (key in path_count1.keys()) else 0)
  297. for key in all_paths]
  298. vector2 = [(path_count2[key] if (key in path_count2.keys()) else 0)
  299. for key in all_paths]
  300. kernel = np.sum(np.minimum(vector1, vector2)) / \
  301. np.sum(np.maximum(vector1, vector2))
  302. return kernel
  303. def wrapper_uhpath_do_naive(k_func, itr):
  304. i = itr[0]
  305. j = itr[1]
  306. return i, j, _untilhpathkernel_do_naive(G_plist[i], G_plist[j], k_func)
  307. # @todo: (can be removed maybe) this method find paths repetively, it could be faster.
  308. def find_all_paths_until_length(G,
  309. length,
  310. ds_attrs,
  311. node_label='atom',
  312. edge_label='bond_type'):
  313. """Find all paths no longer than a certain maximum length in a graph. A
  314. recursive depth first search is applied.
  315. Parameters
  316. ----------
  317. G : NetworkX graphs
  318. The graph in which paths are searched.
  319. length : integer
  320. The maximum length of paths.
  321. ds_attrs: dict
  322. Dataset attributes.
  323. node_label : string
  324. Node attribute used as label. The default node label is atom.
  325. edge_label : string
  326. Edge attribute used as label. The default edge label is bond_type.
  327. Return
  328. ------
  329. path : list
  330. List of paths retrieved, where for unlabeled graphs, each path is
  331. represented by a list of nodes; while for labeled graphs, each path is
  332. represented by a list of strings consists of labels of nodes and/or
  333. edges on that path.
  334. """
  335. # path_l = [tuple([n]) for n in G.nodes] # paths of length l
  336. # all_paths = path_l[:]
  337. # for l in range(1, length + 1):
  338. # path_l_new = []
  339. # for path in path_l:
  340. # for neighbor in G[path[-1]]:
  341. # if len(path) < 2 or neighbor != path[-2]:
  342. # tmp = path + (neighbor, )
  343. # if tuple(tmp[::-1]) not in path_l_new:
  344. # path_l_new.append(tuple(tmp))
  345. # all_paths += path_l_new
  346. # path_l = path_l_new[:]
  347. path_l = [[n] for n in G.nodes] # paths of length l
  348. all_paths = path_l[:]
  349. for l in range(1, length + 1):
  350. path_lplus1 = []
  351. for path in path_l:
  352. for neighbor in G[path[-1]]:
  353. if neighbor not in path:
  354. tmp = path + [neighbor]
  355. # if tmp[::-1] not in path_lplus1:
  356. path_lplus1.append(tmp)
  357. all_paths += path_lplus1
  358. path_l = path_lplus1[:]
  359. # for i in range(0, length + 1):
  360. # new_paths = find_all_paths(G, i)
  361. # if new_paths == []:
  362. # break
  363. # all_paths.extend(new_paths)
  364. # consider labels
  365. # print(paths2labelseqs(all_paths, G, ds_attrs, node_label, edge_label))
  366. return paths2labelseqs(all_paths, G, ds_attrs, node_label, edge_label)
  367. def wrapper_find_all_paths_until_length(length, ds_attrs, node_label,
  368. edge_label, itr_item):
  369. g = itr_item[0]
  370. i = itr_item[1]
  371. return i, find_all_paths_until_length(g, length, ds_attrs,
  372. node_label=node_label, edge_label=edge_label)
  373. def find_all_path_as_trie(G,
  374. length,
  375. ds_attrs,
  376. node_label='atom',
  377. edge_label='bond_type'):
  378. # time1 = time.time()
  379. # all_path = find_all_paths_until_length(G, length, ds_attrs,
  380. # node_label=node_label,
  381. # edge_label=edge_label)
  382. # ptrie = Trie()
  383. # for path in all_path:
  384. # ptrie.insertWord(path)
  385. # ptrie = Trie()
  386. # path_l = [[n] for n in G.nodes] # paths of length l
  387. # path_l_str = paths2labelseqs(path_l, G, ds_attrs, node_label, edge_label)
  388. # for p in path_l_str:
  389. # ptrie.insertWord(p)
  390. # for l in range(1, length + 1):
  391. # path_lplus1 = []
  392. # for path in path_l:
  393. # for neighbor in G[path[-1]]:
  394. # if neighbor not in path:
  395. # tmp = path + [neighbor]
  396. ## if tmp[::-1] not in path_lplus1:
  397. # path_lplus1.append(tmp)
  398. # path_l = path_lplus1[:]
  399. # # consider labels
  400. # path_l_str = paths2labelseqs(path_l, G, ds_attrs, node_label, edge_label)
  401. # for p in path_l_str:
  402. # ptrie.insertWord(p)
  403. #
  404. # print(time.time() - time1)
  405. # print(ptrie.root)
  406. # print()
  407. # traverse all paths up to length h in a graph and construct a trie with
  408. # them. Deep-first search is applied. Notice the reverse of each path is
  409. # also stored to the trie.
  410. def traverseGraph(root, ptrie, length, G, ds_attrs, node_label, edge_label,
  411. pcurrent=[]):
  412. if len(pcurrent) < length + 1:
  413. for neighbor in G[root]:
  414. if neighbor not in pcurrent:
  415. pcurrent.append(neighbor)
  416. plstr = paths2labelseqs([pcurrent], G, ds_attrs,
  417. node_label, edge_label)
  418. ptrie.insertWord(plstr[0])
  419. traverseGraph(neighbor, ptrie, length, G, ds_attrs,
  420. node_label, edge_label, pcurrent)
  421. del pcurrent[-1]
  422. ptrie = Trie()
  423. path_l = [[n] for n in G.nodes] # paths of length l
  424. path_l_str = paths2labelseqs(path_l, G, ds_attrs, node_label, edge_label)
  425. for p in path_l_str:
  426. ptrie.insertWord(p)
  427. for n in G.nodes:
  428. traverseGraph(n, ptrie, length, G, ds_attrs, node_label, edge_label,
  429. pcurrent=[n])
  430. # def traverseGraph(root, all_paths, length, G, ds_attrs, node_label, edge_label,
  431. # pcurrent=[]):
  432. # if len(pcurrent) < length + 1:
  433. # for neighbor in G[root]:
  434. # if neighbor not in pcurrent:
  435. # pcurrent.append(neighbor)
  436. # plstr = paths2labelseqs([pcurrent], G, ds_attrs,
  437. # node_label, edge_label)
  438. # all_paths.append(pcurrent[:])
  439. # traverseGraph(neighbor, all_paths, length, G, ds_attrs,
  440. # node_label, edge_label, pcurrent)
  441. # del pcurrent[-1]
  442. #
  443. #
  444. # path_l = [[n] for n in G.nodes] # paths of length l
  445. # all_paths = path_l[:]
  446. # path_l_str = paths2labelseqs(path_l, G, ds_attrs, node_label, edge_label)
  447. ## for p in path_l_str:
  448. ## ptrie.insertWord(p)
  449. # for n in G.nodes:
  450. # traverseGraph(n, all_paths, length, G, ds_attrs, node_label, edge_label,
  451. # pcurrent=[n])
  452. # print(ptrie.root)
  453. return ptrie
  454. def wrapper_find_all_path_as_trie(length, ds_attrs, node_label,
  455. edge_label, itr_item):
  456. g = itr_item[0]
  457. i = itr_item[1]
  458. return i, find_all_path_as_trie(g, length, ds_attrs,
  459. node_label=node_label, edge_label=edge_label)
  460. def paths2labelseqs(plist, G, ds_attrs, node_label, edge_label):
  461. if ds_attrs['node_labeled']:
  462. if ds_attrs['edge_labeled']:
  463. path_strs = [
  464. tuple(
  465. list(
  466. chain.from_iterable(
  467. (G.node[node][node_label],
  468. G[node][path[idx + 1]][edge_label])
  469. for idx, node in enumerate(path[:-1]))) +
  470. [G.node[path[-1]][node_label]]) for path in plist
  471. ]
  472. # path_strs = []
  473. # for path in all_paths:
  474. # strlist = list(
  475. # chain.from_iterable((G.node[node][node_label],
  476. # G[node][path[idx + 1]][edge_label])
  477. # for idx, node in enumerate(path[:-1])))
  478. # strlist.append(G.node[path[-1]][node_label])
  479. # path_strs.append(tuple(strlist))
  480. else:
  481. path_strs = [
  482. tuple([G.node[node][node_label] for node in path])
  483. for path in plist
  484. ]
  485. return path_strs
  486. else:
  487. if ds_attrs['edge_labeled']:
  488. return [
  489. tuple([] if len(path) == 1 else [
  490. G[node][path[idx + 1]][edge_label]
  491. for idx, node in enumerate(path[:-1])
  492. ]) for path in plist
  493. ]
  494. else:
  495. return [tuple(['0' for node in path]) for path in plist]
  496. # return [tuple([len(path)]) for path in all_paths]
  497. #
  498. #def paths2GSuffixTree(paths):
  499. # return Tree(paths, builder=ukkonen.Builder)
  500. # def find_paths(G, source_node, length):
  501. # """Find all paths no longer than a certain length those start from a source node. A recursive depth first search is applied.
  502. # Parameters
  503. # ----------
  504. # G : NetworkX graphs
  505. # The graph in which paths are searched.
  506. # source_node : integer
  507. # The number of the node from where all paths start.
  508. # length : integer
  509. # The length of paths.
  510. # Return
  511. # ------
  512. # path : list of list
  513. # List of paths retrieved, where each path is represented by a list of nodes.
  514. # """
  515. # return [[source_node]] if length == 0 else \
  516. # [[source_node] + path for neighbor in G[source_node]
  517. # for path in find_paths(G, neighbor, length - 1) if source_node not in path]
  518. # def find_all_paths(G, length):
  519. # """Find all paths with a certain length in a graph. A recursive depth first search is applied.
  520. # Parameters
  521. # ----------
  522. # G : NetworkX graphs
  523. # The graph in which paths are searched.
  524. # length : integer
  525. # The length of paths.
  526. # Return
  527. # ------
  528. # path : list of list
  529. # List of paths retrieved, where each path is represented by a list of nodes.
  530. # """
  531. # all_paths = []
  532. # for node in G:
  533. # all_paths.extend(find_paths(G, node, length))
  534. # # The following process is not carried out according to the original article
  535. # # all_paths_r = [ path[::-1] for path in all_paths ]
  536. # # # For each path, two presentation are retrieved from its two extremities. Remove one of them.
  537. # # for idx, path in enumerate(all_paths[:-1]):
  538. # # for path2 in all_paths_r[idx+1::]:
  539. # # if path == path2:
  540. # # all_paths[idx] = []
  541. # # break
  542. # # return list(filter(lambda a: a != [], all_paths))
  543. # return all_paths

A Python package for graph kernels, graph edit distances and graph pre-image problem.