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

Implements all-pairs shortest paths in parallel #2265

Closed
wants to merge 1 commit into from

Conversation

jfinkels
Copy link
Contributor

This commit modifies the implementation of the unweighted all-pairs
shortest paths to use the multiprocessing module.

This pull request is intended to experiment with employing parallelism directly within NetworkX. See issue #356.

@jfinkels
Copy link
Contributor Author

The tests fail because I used the multiprocessing.Pool class as a context manager, but Pool did not become a context manager until Python 3.3. PyPy3 also fails because on Travis it only supports Python 3.2. I'm sure it's no problem to adapt this to work without the context manager, but I'd like to get feedback on this approach before continuing work on this branch.

@progval
Copy link
Contributor

progval commented Sep 27, 2016

It would also be nice to have it work without multiprocessing, as it does not work on all platforms, like Jython, or Linux distributions without the right permissions on /dev/shm.

@jfinkels
Copy link
Contributor Author

The Jython website seems to indicate that there is a Jython 2.7.0 final release that supports Python 2.7, which should include multiprocessing, is that correct?

Does the implementation of multiprocessing always use the shared memory at /dev/shm on Linux systems?

@progval
Copy link
Contributor

progval commented Sep 27, 2016

The Jython website seems to indicate that there is a Jython 2.7.0 final release that supports Python 2.7, which should include multiprocessing, is that correct?

I don't think so. Jython provides “real” threads in the threading module, so multiprocessing is irrelevant.

Does the implementation of multiprocessing always use the shared memory at /dev/shm on Linux systems?

I don't know, but I have received several bug reports related to this for one of my projects.

@jfinkels
Copy link
Contributor Author

I don't think so. Jython provides “real” threads in the threading module, so multiprocessing is irrelevant.

I wouldn't say it's irrelevant, I'm sure there are situations in which I might want to have multiple processes performing some work instead of multiple threads. Also, for the sake of maintainability and portability, if I want to write a program that runs on both CPython and Jython (and whatever other Python implementation you like), I might want to just write my program so that it uses multiprocessing because the API is simple, assuming each Python implementation meets the same API (as is the case with me writing this code for NetworkX right now :D).

I don't know, but I have received several bug reports related to this for one of my projects.

Hm, interesting. That's valuable feedback, thanks for forwarding it.

Copy link
Member

@hagberg hagberg left a comment

Choose a reason for hiding this comment

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

Maybe this could be an example? So far we are not committing to any particular parallel programming model for networkx.

@hagberg hagberg added this to the networkx-future milestone Dec 4, 2016
This commit modifies the implementation of the unweighted all-pairs
shortest paths to use the multiprocessing module.
@MridulS
Copy link
Member

MridulS commented Feb 2, 2023

To be discussed further in #4064 and #6306

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

Successfully merging this pull request may close these issues.

None yet

4 participants