KNeighborsGraph giotto-tda example
Example: KNeighborsGraph giotto-tda example
>>> import numpy as np
>>> from gtda.graphs import KNeighborsGraph
>>> X = np.array([[[0, 1, 3, 0, 0],
... [1, 0, 5, 0, 0],
... [3, 5, 0, 4, 0],
... [0, 0, 4, 0, 0]]])
>>> kng = KNeighborsGraph(n_neighbors=2)
>>> Xg = kng.fit_transform(X)
>>> print(Xg[0].toarray())
[[0. 1. 0. 1.]
[1. 0. 0. 1.]
[1. 0. 0. 1.]
[1. 1. 0. 0.]]