Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified for Python 3.9+ and Cython 3.0+ #46

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f557c3c
Modified for Python 3.9+ and Cython 3.0+
AminAlam Nov 9, 2023
92420b5
Update setup.py
AminAlam Mar 15, 2024
e9a2c81
Create python-publish.yml
AminAlam Mar 15, 2024
ab63058
Update python-publish.yml
AminAlam Mar 15, 2024
ab2c017
Update README.md
AminAlam Mar 15, 2024
9b9466c
Update fa2util.c
AminAlam Mar 17, 2024
321fe5e
Update python-publish.yml
AminAlam Mar 17, 2024
e07b8cf
Update fa2util.c
AminAlam Mar 17, 2024
251f66a
Update README.md
AminAlam Mar 17, 2024
5e7f98b
Update README.md
AminAlam Mar 17, 2024
f8021d9
fa2->fa2_modified
AminAlam Mar 17, 2024
cf60d7f
Update python-publish.yml
AminAlam Mar 17, 2024
4f7e9f0
Update python-publish.yml
AminAlam Mar 17, 2024
fc68a55
Update python-publish.yml
AminAlam Mar 17, 2024
deefa43
Update README.md
AminAlam Mar 18, 2024
ca5fd13
Update python-publish.yml
AminAlam Mar 18, 2024
9ae8191
Update README.md
AminAlam Mar 18, 2024
f87f41e
Update forceatlas2.py
AminAlam Apr 15, 2024
4e8ae85
Delete fa2_modified/fa2util.c
AminAlam Apr 16, 2024
8ca18d9
Update setup.py
AminAlam Apr 16, 2024
b90c6c2
Update python-publish.yml
AminAlam Apr 16, 2024
9b6733c
fa2util2.c is added as a package data
AminAlam Apr 16, 2024
cecbead
Update setup.py
AminAlam Apr 16, 2024
163813f
Update setup.py
AminAlam Apr 16, 2024
9405b05
pip now acknowledges cython
AminAlam Apr 16, 2024
08767cd
readme update
AminAlam Apr 16, 2024
cef168c
manulinux distro
AminAlam Apr 16, 2024
7a3970e
entry point for python removed
AminAlam Apr 16, 2024
7494a6b
entry point for python removed
AminAlam Apr 16, 2024
9f8de32
auditwheel added
AminAlam Apr 16, 2024
a7fae01
old x86 linux wheels removed
AminAlam Apr 16, 2024
eae587f
Update README.md
AminAlam Apr 18, 2024
8f769ff
Update forceatlas2.py
n-elie May 7, 2024
f1cf9a8
Merge pull request #1 from metgem:master
AminAlam May 7, 2024
05a01c9
test added
AminAlam May 7, 2024
da1ad1a
new version
AminAlam May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: docker://quay.io/pypa/manylinux2014_x86_64
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine auditwheel
- name: Build package
run: |
python3 -m pip install --upgrade build
python3 -m build
- name: Repair wheels
run: |
auditwheel repair --wheel-dir dist dist/*.whl
rm -rf dist/*linux_x86_64*.whl
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN_GITHUB }}
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include fa2/fa2util.c
include fa2/fa2util.pxd
include fa2_modified/fa2util.pxd
include examples/*
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## ForceAtlas2 for Python
## ForceAtlas2 for Python3 (modified/maintained version)

A port of Gephi's Force Atlas 2 layout algorithm to Python 2 and Python 3 (with a wrapper for NetworkX and igraph). This is the fastest python implementation available with most of the features complete. It also supports Barnes Hut approximation for maximum speedup.
#### This is a maintained version of fa2 [python library](https://github.com/bhargavchippada/forceatlas2). The source code is same as fa2, but this repo can be installed on Python 3.9+ whereas the original fa2 only runs on Python <3.8.
--------



A port of Gephi's Force Atlas 2 layout algorithm to Python 3 (with a wrapper for NetworkX and igraph). This is the fastest python implementation available with most of the features complete. It also supports Barnes Hut approximation for maximum speedup.

ForceAtlas2 is a very fast layout algorithm for force-directed graphs. It's used to spatialize a **weighted undirected** graph in 2D (Edge weight defines the strength of the connection). The implementation is based on this [paper](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0098679) and the corresponding [gephi-java-code](https://github.com/gephi/gephi/blob/master/modules/LayoutPlugin/src/main/java/org/gephi/layout/plugin/forceAtlas2/ForceAtlas2.java). Its really quick compared to the fruchterman reingold algorithm (spring layout) of networkx and scales well to high number of nodes (>10000).

Expand All @@ -15,7 +20,7 @@ ForceAtlas2 is a very fast layout algorithm for force-directed graphs. It's used

Install from pip:

pip install fa2
pip install fa2_modified

To build and install run from source:

Expand All @@ -41,7 +46,7 @@ To build and install run from source:

## Usage

from fa2 import ForceAtlas2
from fa2_modified import ForceAtlas2

Create a ForceAtlas2 object with the appropriate settings. ForceAtlas2 class contains three important methods:
```python
Expand Down Expand Up @@ -70,7 +75,7 @@ Below is an example usage. You can also see the feature settings of ForceAtlas2

```python
import networkx as nx
from fa2 import ForceAtlas2
from fa2_modified import ForceAtlas2
import matplotlib.pyplot as plt

G = nx.random_geometric_graph(400, 0.2)
Expand Down
10 changes: 5 additions & 5 deletions examples/forceatlas2-layout.ipynb

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions examples/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import networkx as nx
from fa2_modified import ForceAtlas2
import matplotlib.pyplot as plt

G = nx.random_geometric_graph(400, 0.2)

forceatlas2 = ForceAtlas2(
# Behavior alternatives
outboundAttractionDistribution=True, # Dissuade hubs
linLogMode=False, # NOT IMPLEMENTED
adjustSizes=False, # Prevent overlap (NOT IMPLEMENTED)
edgeWeightInfluence=1.0,

# Performance
jitterTolerance=1.0, # Tolerance
barnesHutOptimize=True,
barnesHutTheta=1.2,
multiThreaded=False, # NOT IMPLEMENTED

# Tuning
scalingRatio=2.0,
strongGravityMode=False,
gravity=1.0,

# Log
verbose=True)

positions = forceatlas2.forceatlas2_networkx_layout(G, pos=None, iterations=2000)
nx.draw_networkx_nodes(G, positions, node_size=20, node_color="blue", alpha=0.4)
nx.draw_networkx_edges(G, positions, edge_color="green", alpha=0.05)
plt.axis('off')
plt.show()
Loading