Last active
June 3, 2020 18:05
-
-
Save alifarazz/fc8e10f15d2463fdb9b94177bb4007b4 to your computer and use it in GitHub Desktop.
Get minimum Euclidean distance between points in an XY plane using O(n.lgn).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scipy import spatial | |
| import numpy as np | |
| pos = np.c_[np.random.rand(100), np.random.rand(100)] | |
| tree = spatial.cKDTree(pos) | |
| dist, ids = tree.query(pos, 2) | |
| print(f'min dist: {np.min(dist[:, 1]): 8f}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment