Repository navigation
Clarify that bfs_predecessors() does not actually search through predecessors - #8445
Conversation
make it closer to @Swaritz's comment in networkx#8442, which explains the situation well
|
Question: would this https://networkx.org/documentation/stable/reference/classes/generated/networkx.DiGraph.reverse.html have solved your original problem? Might be worth mentioning it in the docs update. |
dschult
left a comment
There was a problem hiding this comment.
Since there isn't currently a paragraph description of what this function does, the warning pragraph seems out of place. Can we resolve most of the confusion be starting with a paragraph on what this actually does return, so the warning can be an add-on sentence at the end?
Perhaps something like:
The yielded node pairs are each node along with its predecessor in the
breadth-first-search. That is, the predecessor is the node from which the
BFS moved directly to the node indicated. This should not be confused
with the more general term predecessors of nodes in directed graphs.
|
Thank you!
It would have helped a bit; however, the main thing I was trying to achieve was finding all nodes within some distance of a given set of source nodes in a directed graph (ignoring edge directionality). So, I wanted to search both backwards and forwards. I ended up doing this by using
Understood. I added a paragraph explaining the return value of the function, and adjusted the warning accordingly. The warning is currently included as a second paragraph below the return-value explanation paragraph; I think being explicit in the warning will make this documentation easier to interpret than having it be a single add-on sentence. However, if you would prefer the clarification be shortened, I can change that. |
rossbar
left a comment
There was a problem hiding this comment.
IMO the added wording is quite dense and doesn't necessarily relate to the function itself, but rather higher-level terminology. IMO the info in the first sentence is adequately captured in the return type description.
If anything, I'd vote for simply noting that bfs_predecessors is equivalent to yield (t, s) for s, t in bfs_edges(G, source)
Happy to rewrite things as needed. Maybe trimming down the second paragraph to something like ... if that is acceptable?
If you would like I can remove the first sentence or paragraph, although I believe this would contradict @dschult's request. Or maybe rewriting the first paragraph to be more "casual" would make sense?
This is a very elegant way of expressing this, but I suspect it is impenetrable to anyone who doesn't already know the NetworkX API -- it is not immediately obvious what So far multiple people (at least me and #710) have seen this function's documentation, skimmed it, and assumed that it searched backwards -- this assumption matches the majority of other uses of the term For this reason, I am in favor of adding some sort of warning to avoid other people going down similar rabbit holes. |
Implement @dschult's changes Co-authored-by: Dan Schult <[email protected]>
|
Thank you, @dschult! I added your suggestion, plus a small grammar edit. |
Adds a paragraph to the docs of
bfs_predecessors()addressing the confusion I had in #8442. This confusion has also been brought up in #710.I tried to keep the wording fairly casual here; I think being explicit about this is best. Please let me know if you'd like any edits.