Skip to main content

Bindings to full Rust ForceAtlas2 implementation

Project description

ForceAtlas2 Python bindings from Rust

Python 3 bindings for Rust forceatlas2 crate: fast force-based graph spacialization layout, with optional multithread and SIMD.

Example graph spacialized with ForceAtlas2

Note: Cross-compiling with PyO3 is hard, so the distributed binary only works for GNU/Linux with latest versions of glibc (typically not Debian). Any help with cross-compilation or static glibc linking is welcome. :)

Example

import fa2rs

edges = [(0,1), (1,2), (2,0), (2,3)]
layout = fa2rs.Layout.from_graph(edges, fa2rs.Settings(ka=0.1, kg=0.1, kr=0.1), nb_nodes=4)

for i in range(100):
    layout.iteration()

print(layout.points)

You may need to tweak the settings to fit your data. The most important parameter is the ratio between ka and kr. If the ratio has too low or high values, the graph will collapse or explode (resulting in zero or infinite values).

  • ka: attraction coefficient (all neighbor nodes attract each other)
  • kg: gravity coefficient (all nodes are attracted to the origin) (can be set to 0)
  • kr: repulsion coefficient (all nodes repulse each other)
  • chunk_size: decrease to use more threads, increase to use fewer threads. Tune it to minimize both thread management time and unparallelized time. Set to None to disable parallelization.

Build & install

Build:

sh build_wheel.sh

Install:

pip3 install target/wheel/dist/fa2rs-0.2.1-py3-none-any.whl --upgrade

More information about optimizations on the Rust repository.

Layout and Settings are aliases for Layout32 and Settings32. The 32 and 64 versions refer to the size of the floats. 64-bit floats are more precise, but when SIMD is available, the layout is approximately twice slower than with 32-bit floats.

SIMD is only available on x86 and x86_64 with avx2 feature. (check with grep avx2 /proc/cpuinfo)

License

GNU AGPL v3, CopyLeft 2020-2021 Pascal Engélibert
The ForceAtlas2 paper was released under CC BY, Copyright 2014 Jacomy et al.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fa2rs-0.3.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fa2rs-0.3.2-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file fa2rs-0.3.2.tar.gz.

File metadata

  • Download URL: fa2rs-0.3.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for fa2rs-0.3.2.tar.gz
Algorithm Hash digest
SHA256 1883b0bdba46d38d460c98b00a3dd4fa0c4ca630fa6a8d8e1a55779e1efdd66f
MD5 76e411883017ef9215fd67e94117f515
BLAKE2b-256 a3f7f3b6320bd8ca9d5297815bf481be4fd8dda0e4997eb81a4e5daccf6d3eee

See more details on using hashes here.

File details

Details for the file fa2rs-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: fa2rs-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for fa2rs-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b1fa4f99d8cc4aec132b88a6424a3d5834cf0adbe1f06d28d70c8a1d6ac63bde
MD5 7761c4035633458b9ad3ef3102fca4f5
BLAKE2b-256 299d8acdc46d1a563878ad7bb1f4513563c95662f308106930e018c0dd0b753a

See more details on using hashes here.

Supported by

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