Skip to main content

Efficient Implementation of Sparse Graphs with Numpy

Project description

Usage

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

dense_graph

image1

10x more edges in the dense graph in comparison to the sparse graph.

To Experiment

Import this module in the method module.

Project details


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

sparse_graphs-0.0.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file sparse_graphs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: sparse_graphs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for sparse_graphs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 393a7e96e7f40491ea1aab651bdcd372bcdaca9ebc48bef594068ff7adaa08ee
MD5 8f27c61e240567552d3a8a44d5093938
BLAKE2b-256 f9b851d35cf1c9b883c1be43559cd41cf36c0bbe13bb8b9443f056a7d335f712

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page