MultiMatchingResult

class pygmtools.utils.MultiMatchingResult(cycle_consistent=False, backend=None)[source]

A memory-efficient class for multi-graph matching results. For non-cycle consistent results, the dense storage for \(m\) graphs with \(n\) nodes requires a size of \((m\times m \times n \times n)\), and this implementation requires \(((m-1)\times m \times n \times n / 2)\). For cycle consistent result, this implementation requires only \((m\times n\times n)\).

Numpy Example
>>> import numpy as np
>>> import pygmtools as pygm
>>> np.random.seed(0)

>>> X = pygm.utils.MultiMatchingResult(backend='numpy')
>>> X[0, 1] = np.zeros((4, 4))
>>> X[0, 1][np.arange(0, 4, dtype=np.int64), np.random.permutation(4)] = 1
>>> X
MultiMatchingResult:
{'0,1': array([[0., 0., 1., 0.],
    [0., 0., 0., 1.],
    [0., 1., 0., 0.],
    [1., 0., 0., 0.]])}
>>> X[1, 0]
array([[0., 0., 0., 1.],
    [0., 0., 1., 0.],
    [1., 0., 0., 0.],
    [0., 1., 0., 0.]])
static from_numpy(data, device=None, new_backend=None)[source]

Convert a numpy-backend MultiMatchingResult data to another backend.

Parameters
  • data – the numpy-backend data

  • device – (default: None) the target device

  • new_backend – (default: pygmtools.BACKEND variable) the target backend

Returns

a new MultiMatchingResult instance for new_backend on device

from_numpy_(device=None, new_backend=None)[source]

In-place operation for from_numpy().

static to_numpy(data)[source]

Convert an any-type MultiMatchingResult to numpy backend.

Parameters

data – the any-type data

Returns

a new MultiMatchingResult instance for numpy

to_numpy_()[source]

In-place operation for to_numpy().