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 17 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
42 changes: 42 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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:
entrypoint: /usr/local/bin/python3
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build package
run: |
python3 -m pip install --upgrade build
python3 -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN_GITHUB }}
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 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.

A port of Gephi's Force Atlas 2 layout algorithm to Python 3 (Python 3.9) (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 +16,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 +42,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 +71,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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 12 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import setup

print("Installing fa2 package (fastest forceatlas2 python implementation)\n")
print("Installing fa2_modified package (fastest forceatlas2 python implementation)\n")

here = path.abspath(path.dirname(__file__))

Expand All @@ -14,7 +14,7 @@
print(">>>> Cython is installed?")
try:
from Cython.Distutils import Extension
from Cython.Build import build_ext
from Cython.Build import build_ext, cythonize
USE_CYTHON = True
print('Yes\n')
except ImportError:
Expand All @@ -25,35 +25,34 @@
print(">>>> Are pre-generated C files available?")

if USE_CYTHON:
ext_modules = [Extension('fa2.fa2util', ['fa2/fa2util.py', 'fa2/fa2util.pxd'], cython_directives={'language_level' : 3})]
ext_modules = cythonize([Extension('fa2_modified.fa2util', ['fa2_modified/fa2util.py'], cython_directives={'language_level' : 3})])
cmdclass = {'build_ext': build_ext}
opts = {"ext_modules": ext_modules, "cmdclass": cmdclass}
elif path.isfile(path.join(here, 'fa2/fa2util.c')):
elif path.isfile(path.join(here, 'fa2_modified/fa2util.c')):
print("Yes\n")
ext_modules = [Extension('fa2.fa2util', ['fa2/fa2util.c'])]
ext_modules = [Extension('fa2_modified.fa2util', ['fa2_modified/fa2util.c'])]
cmdclass = {}
opts = {"ext_modules": ext_modules, "cmdclass": cmdclass}
else:
print("Pre-generated C files are not available. This library will be slow without Cython optimizations.\n")
opts = {"py_modules": ["fa2.fa2util"]}
opts = {"py_modules": ["fa2_modified.fa2util"]}

# Uncomment the following line if you want to install without optimizations
# opts = {"py_modules": ["fa2.fa2util"]}

print(">>>> Starting to install!\n")

setup(
name='fa2',
name='fa2_modified',
version='0.3.5',
description='The fastest ForceAtlas2 algorithm for Python (and NetworkX)',
long_description_content_type='text/markdown',
long_description=long_description,
author='Bhargav Chippada',
author_email='bhargavchippada19@gmail.com',
url='https://github.com/bhargavchippada/forceatlas2',
download_url='https://github.com/bhargavchippada/forceatlas2/archive/v0.3.5.tar.gz',
author='Bhargav Chippada, Amin Alam',
url='https://github.com/AminAlam/forceatlas2_maintained',
download_url='https://github.com/AminAlam/forceatlas2_maintained/archive/refs/tags/V0.0.1.tar.gz',
keywords=['forceatlas2', 'networkx', 'force-directed-graph', 'force-layout', 'graph'],
packages=['fa2'],
packages=['fa2_modified'],
classifiers=[
'Development Status :: 5 - Production/Stable',

Expand All @@ -72,4 +71,4 @@
},
include_package_data=True,
**opts
)
)