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.

random_walk.py 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Wed Aug 19 16:55:17 2020
  5. @author: ljia
  6. @references:
  7. [1] S Vichy N Vishwanathan, Nicol N Schraudolph, Risi Kondor, and Karsten M Borgwardt. Graph kernels. Journal of Machine Learning Research, 11(Apr):1201–1242, 2010.
  8. """
  9. from gklearn.kernels import SylvesterEquation, ConjugateGradient, FixedPoint, SpectralDecomposition
  10. class RandomWalk(SylvesterEquation, ConjugateGradient, FixedPoint, SpectralDecomposition):
  11. def __init__(self, **kwargs):
  12. self._compute_method = kwargs.get('compute_method', None)
  13. self._compute_method = self._compute_method.lower()
  14. if self._compute_method == 'sylvester':
  15. self._parent = SylvesterEquation
  16. elif self._compute_method == 'conjugate':
  17. self._parent = ConjugateGradient
  18. elif self._compute_method == 'fp':
  19. self._parent = FixedPoint
  20. elif self._compute_method == 'spectral':
  21. self._parent = SpectralDecomposition
  22. elif self._compute_method == 'kon':
  23. raise Exception('This computing method is not completed yet.')
  24. else:
  25. raise Exception('This computing method does not exist. The possible choices inlcude: "sylvester", "conjugate", "fp", "spectral".')
  26. self._parent.__init__(self, **kwargs)
  27. def _compute_gm_series(self):
  28. return self._parent._compute_gm_series(self)
  29. def _compute_gm_imap_unordered(self):
  30. return self._parent._compute_gm_imap_unordered(self)
  31. def _compute_kernel_list_series(self, g1, g_list):
  32. return self._parent._compute_kernel_list_series(self, g1, g_list)
  33. def _compute_kernel_list_imap_unordered(self, g1, g_list):
  34. return self._parent._compute_kernel_list_imap_unordered(self, g1, g_list)
  35. def _compute_single_kernel_series(self, g1, g2):
  36. return self._parent._compute_single_kernel_series(self, g1, g2)

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