Skip to content

Added forceatlas2 layout - #5311

Closed
cvanelteren wants to merge 2 commits into
networkx:mainfrom
cvanelteren:forceatlas2
Closed

cvanelteren wants to merge 2 commits into
networkx:mainfrom
cvanelteren:forceatlas2

Conversation

@cvanelteren

Copy link
Copy Markdown
Contributor

Added forceatlas 2 layout

I've added the ForceAtlas2 layout from gephi that was implemented by bhargavchippada with linLog merge from victorbenichoux. The ForceAtlas2 layout forms a fast alternative for spring layout and work particularly well for large graphs. It originates from gephi and is a good addition to the networkx toolkit.

Best wishes,
C

@cvanelteren
cvanelteren force-pushed the forceatlas2 branch 2 times, most recently from a9d4f44 to 365f1c7 Compare February 9, 2022 06:12
@cvanelteren

Copy link
Copy Markdown
Contributor Author

Not entirely sure what goes wrong with the build here. This installs for me locally and runs properly. Perhaps one of the maintainers can shed some light on the build environment to make it congruent.

@MridulS

MridulS commented Feb 9, 2022

Copy link
Copy Markdown
Member

Thanks for this @cvanelteren!

There are merge conflicts in one of the file plus we don't setup git submodules while running the CI.

I'm generally -1 on adding code through submodules. It would be super great if we could get this in if someone can port
the code to python and networkx. We could add the package as a dependency and use it but I'm not too excited about new dependencies too.

@cvanelteren

Copy link
Copy Markdown
Contributor Author

Hi @MridulS! Thanks for clarifying, it was what I suspected. The dependency I understand. The original implementation seems to be pretty low on activity. There are some full features missing from forceatlas2 (judging from the python code) that I may develop at some future stage. However, in its current stage it is highly usable and functioning. I think it would be a valuable addition to networkx.

What do you mean exactly with porting it to python and networkx? The code in its current format has an optional dependency for cython, but will otherwise use either the precompiled code or the cython code in pure mode (python mode). To clarify, the default mode is pure python. Converting is loses this flexibility, but I could aid in this too.
Cheers,
C

@jarrodmillman

Copy link
Copy Markdown
Member

@cvanelteren

Copy link
Copy Markdown
Contributor Author

Correct @jarrodmillman but that does not prevent noncommercial.

@MridulS

MridulS commented Feb 10, 2022

Copy link
Copy Markdown
Member

What do you mean exactly with porting it to python and networkx?

When I saw cython as a dependency I thought parts of it were written in Cython, but that doesn't seem to be the case. thanks for pointing it out.

We can't include GPL code with NetworkX (this would require re-licensing the code base from BSD to GPL, this is at least what I understand IANAL).
If it stays as an optional dependency I'm not sure how it works out (the dynamic linking of GPL code. I am no expert)

@cvanelteren

Copy link
Copy Markdown
Contributor Author

Ah gotcha. Also no expert here on the licensing with optional dependencies. Let me know if you need my help on anything code related.

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm generally +1 about adding this layout function (it seems quite popular) but -1 on vendoring an external project like this. In principle we could add an example to the gallery showing how to use forceatlas2 as an external proejct, but I'd even be -1 about that as it looks like the linked code hasn't been updated in 2 years and the last release was Jan. 2019.

@MridulS

MridulS commented Mar 4, 2022

Copy link
Copy Markdown
Member

@cvanelteren I'm going to close this for now, but thanks for starting up the conversation! I would like to see ForceAtlas2 included, but implemented specifically for NetworkX. The original paper https://doi.org/10.1371/journal.pone.0098679 would be good starting point :)

@MridulS MridulS closed this Mar 4, 2022
@cvanelteren

cvanelteren commented Mar 13, 2022 •

Copy link
Copy Markdown
Contributor Author

@MridulS ok deal, I have implemented the forceatlas2 based on the paper in native python with networkx. Will perform a pull request later this week when I cleaned up the code a bit.

Initial speed is a lot slower than the cython implementation. How does the development team stand on providing a cython or other lower level implenentation for the utility functions in the build process? People have done something similar in the past e.g. https://pypi.org/project/cynetworkx/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants