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

Return paths as a generator instead of list #1088

Open
sambaPython24 opened this issue Feb 12, 2024 · 1 comment
Open

Return paths as a generator instead of list #1088

sambaPython24 opened this issue Feb 12, 2024 · 1 comment
Labels

Comments

@sambaPython24
Copy link

What is the expected enhancement?

networkx returns a generator from e.g. rx.all_simple_paths. That is useful for very large graphs with many possible paths, since
we can loop over the generator without filling the memory and break if other conditions are fulfilled.

Ps.: The documentation for rx.all_simple_paths needs to be fixed: the arguments name is not from_ but origin.
(Signature: rx.all_simple_paths(graph, from_, to, min_depth=None, cutoff=None)

@IvanIsCoding
Copy link
Collaborator

It would be nice but it would require a major redesign in the way we do iterators. Until coroutines are stable we don't really have an equivalent for Python's yield keyword that is trivial to implement.

With regards to the from_ argument, the argument has different names in the type-agnostic all_simple_paths and the type-specific digraph_all_simple_paths. But it is a positional-only argument so it doesn't matter

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

No branches or pull requests

2 participants