Efficient Implementation of Sparse Graphs with Numpy
Project description
To instantiate a graph:
graph = AsymMesh(n=10_000, k=6, dim=2, img_dim=[2], kernel_fn=l2, embed_fn=id2D, d_max=20)
graph.extend(xys, images=xys, meta=xys)
graph.update_zs()
graph.update_edges()
Most of the time it is better to enforce sparsity of the graph by only adding new vertices when there is no existing vertex that is close-by. The new dedupe API allows us to do this in a batch fashion:
spots = graph.dedupe(images=xys, r_min=r_min)
xys = xys[spots]
ds = graph.to_goal(zs_2=xys)
if ds.size == 0:
graph.extend(xys, images=xys, meta=xys)
else:
m = ds.min(axis=-1) >= r_min
if m.sum() > 0:
graph.extend(xys[m], images=xys[m], meta=xys[m])
graph.update_edges()
Dense |
Sparse |
Details |
---|---|---|
10x more edges in the dense graph in comparison to the sparse graph. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for sparse_graphs-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 701efa4ce00a40f1c82cead99c13a1b9320db20c90cd4657508b4f0ec747406d |
|
MD5 | a5af9a8c33f60d0bfe1ceddc418943e0 |
|
BLAKE2b-256 | 7ca93d36bac9081487066a6bbbcb828b84aeaf66e5d5e0b7cbf2e5ff3c2701a3 |