-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add targets argument to all_simple_paths #3138
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
Conversation
|
Hi, I'm Mr. K and I got sent here from #3158. I fear I may be repeating myself, but this is a pull request. |
|
Yes -- this is the right place -- you can ask for someone to review the PR in the upper right. But @ericmjl has already done that -- probably in response to the Issue you created. My first impressions about this change are that it introduces an awkward API for a fairly special case. But I'm open to discussion about that. The API has two ways to specify the target. Maybe we should split this into two functions the way the shortest_path functions got split out: the existing API for single targets and a new function for multiple targets case. Before doing that we should make sure that this is not just me not seeing the API correctly. Can you describe the API in a simple way? How would you tell someone how to use this function? |
|
I completely agree that the proposed interface is awkward. I kept the One option is to have def all_simple_paths(G, source, target, cutoff=None):
return all_simple_paths_targets(G, source, [target], cutoff=cutoff) |
|
Bump. |
|
I'd like to handle the singleton vs container input question the way we handle it in other parts of the code (like Then I'd like to keep the keyword name as "target" but make it clear in the documentation that it can be a container of nodes. The idea there is that "a target" does not have to be a single node. Just as an archery target includes many concentric rings -- "I hit the target" means one of the rings was hit. It also makes backward compatibility more straightforward. :) Does this make any sense? |
|
Yes! I'll have a go at refactoring. |
66e5684 to
26acee8
Compare
|
Here's the refactor. Notes
|
|
Great! Thanks -- You could use |
|
This code looks good. And you've got the docstrings updated which should be all we need for documentation. Can you add some basic tests to the file tests/test_simple_paths.py? Thanks! |
|
I would be happy to.
…On Sun, Oct 14, 2018 at 5:49 AM Dan Schult ***@***.***> wrote:
This code looks good. And you've got the docstrings updated which should
be all we need for documentation. Can you add some basic tests to the file
tests/test_simple_paths.py?
Simple short tests of key functionality is what we're aiming for. I think
that is all that's left before we merge.
Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3138 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASnPoIbpTozD7Dkey3pREimB4j-N3_mks5ukrQpgaJpZM4WXHak>
.
--
Post-doctoral researcher
School of Engineering Sciences in Chemistry, Biotechnology and Health
Department of Gene Technology
SciLifeLab
KTH Royal Institute of Technology
Stockholm, Sweden
|
|
How about this? Also, the test names all have |
|
We usually do put all the tests related to a single construct (ok... and with the same setup required) into a class named TestAllSimplePaths. But obviously it is not always consistent across the package. |
If one is looking to find all simple paths to multiple targets with out-degree 0, then emitting paths for a set of targets instead of each target separately improves big O algorithmic complexity by a factor of m, where m is the number of targets.
Further clarification: Because we are using an exhaustive depth-first search to find all paths to a target, all other targets will also be encountered during that search. This PR changes the algorithm so that those paths are also emitted.
One might not want to use the
targetsargument if any of the targets have out-degree > 0.