Skip to main content

ForceAtlas2 for Python

This is a port of Gephi’s ForceAtlas2 layout algorithm to Python 2 and Python 3 (with a wrapper for NetworkX).

Installation

The only strict dependency is Numpy. Cython is highly recommended, as it will speed it up by a factor of 10-100, depending on the graph. Both can be installed with:

pip install numpy pip install cython

To use the NetworkX wrapper function, you obviously need NetworkX.

Then to install this package, it is the typical:

python setup.py install

Example usage

Two core functions are defined:

  • forceatlas2.forceatlas2 takes an adjacency matrix and optionally initial positions and other optional arguments. It uses this to calculate a layout.

  • forceatlas2.forceatlas2_networkx_layout takes a NetworkX graph and returns a NetworkX-compatible layout.

To use within NetworkX:

import matplotlib.pyplot as plt import networkx import random import forceatlas2 G = networkx.karate_club_graph() pos = { i : (random.random(), random.random()) for i in G.nodes()} # Optionally specify positions as a dictionary l = forceatlas2.forceatlas2_networkx_layout(G, pos, niter=1000) # Optionally specify iteration count networkx.draw_networkx(G, l) plt.show()

Note that my coding style is non-Pythonic, as I don’t use function docstrings. You will have to take a look at the function definition in forceatlas2.py to see a description of all of the potential arguments.

Metadata

Release files for ForceAtlas2 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ForceAtlas2 1.0
File Size Uploaded Provenance Actions
ForceAtlas2-1.0.tar.gz 6.8 kB Without provenance Details for ForceAtlas2-1.0.tar.gz

Release files / ForceAtlas2-1.0.tar.gz

Download URL ForceAtlas2-1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fdc3d3ea7f85b6535598c30ced3b5ccc7b1ac2e49dc486f4a19c6b9fa998a81d
BLAKE2b-256 checksum
How to use checksums
17401966ff5370616809a400085c2e782c0b5f93ed838e437eb2371bc3033414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ForceAtlas2 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page