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
Refactor edmonds algorithm #6743
Conversation
As for "how to do a deprecation", that sounds like something that would be a good section in the contributors guide. I'll try to put down what I understand to be the process here and use this PR as a guinea pig if you are willing. Deprecating code:
Ask is anything isn't clear or doesn't work. :} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! :)
Thanks Matt!
Also, since this is a new function, can you please make the keyword arguments "keyword only" by adding a *, between the positional arguments and the keyword arguments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor suggestions but otherwise LGTM! I'm not too familiar with the Edmond's algorithm so (as always) I rely on the expertise of others :)
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
…o refactor-edmonds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @mjschwenne ! Just one last note about the summary in the new docstring, but other than that this is good to go.
* prep for edmonds refactor * rewrite function initalization * style update * complete algorithm through step I2 * finished rewrite of step I3 * passing max branching tests * attempting to track bugs with arborescence iterators * fixed arborescence iterator bug stemming from weight transformation * Added minimal_branching function * update doc and keyword only args * Update networkx/algorithms/tree/tests/test_branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * move string in original edmonds implementation * fix tests fails caused by keyword only args * try to fix documentation * Minor text/format nits. * tweak minimal_branching documentation --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@caltech.edu>
* prep for edmonds refactor * rewrite function initalization * style update * complete algorithm through step I2 * finished rewrite of step I3 * passing max branching tests * attempting to track bugs with arborescence iterators * fixed arborescence iterator bug stemming from weight transformation * Added minimal_branching function * update doc and keyword only args * Update networkx/algorithms/tree/tests/test_branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * move string in original edmonds implementation * fix tests fails caused by keyword only args * try to fix documentation * Minor text/format nits. * tweak minimal_branching documentation --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@caltech.edu>
* prep for edmonds refactor * rewrite function initalization * style update * complete algorithm through step I2 * finished rewrite of step I3 * passing max branching tests * attempting to track bugs with arborescence iterators * fixed arborescence iterator bug stemming from weight transformation * Added minimal_branching function * update doc and keyword only args * Update networkx/algorithms/tree/tests/test_branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/branchings.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * move string in original edmonds implementation * fix tests fails caused by keyword only args * try to fix documentation * Minor text/format nits. * tweak minimal_branching documentation --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@caltech.edu>
Hello!
I've finished my refactor of Edmond's optimal branching algorithm so it is not dependent on the
Edmonds
class or theMultiDiGraph_EdgeKey
class. The algorithm itself now lives undermaximum_branching
and the other branching and arborescence functions transform the edge weights and use themaximum_branching
function.Things left to do
There are two things that still need to happen here.
Edmonds
class as well asMultiDiGraph_EdgeKey
and theget_path
function inbranching.py
. These classes (and function) are no longer required and always struck me as odd since the rest of the nx codebase doesn't use objects to run algorithms like this. However, I don't know how to deprecate anything in networkx and would appropriate some help getting that setup.minimum_branching
function will return an empty branching for graphs with only positive edge weights since it can choose to not add an edge which will move it further away from the minimum or maximum value. This isn't helpful, isn't documented and should be corrected. I can think of two ways to do this, eitherminimal_branching
which uses the same weight transformation asminimum_spanning_arborescence
but doesn't throw an error when the result isn't an arborescence. This will let us return a branching which will be like an arborescence but doesn't have to span the whole graph and would be useful when the graph has multiple components.minimum_branching
since it really isn't useful right now, although it would require some form of warning to the user that the behavior has changed. I'm not really sure if that's truly a deprecation or something less.