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

Fix custom weight attribute for Mehlhorn #6681

Merged
merged 5 commits into from Mar 10, 2024
Merged

Conversation

kalkoen
Copy link
Contributor

@kalkoen kalkoen commented May 3, 2023

Using a custom weight attribute in the Mehlhorn implementation gave a KeyError. Reason: Edges in G_1_prime are given "weight" attributes, but upon updating, the weight (=/= "weight") of the existing edge in G_1_prime is get. Fix: set and get only "weight" attributes for G_1_prime.

Using a custom weight attribute in the Mehlhorn implementation gave a KeyError. Reason: Edges in G_1_prime are given "weight" attributes, but upon updating, the weight (=/= "weight") of the existing edge in G_1_prime is get. Fix: set and get only "weight" attributes for G_1_prime.
Copy link
Member

@MridulS MridulS left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

I took the liberty of pushing up a couple tests for cases where the edge attribute name is something other than the default "weight". The first test covers the bugfix (i.e. fails on current main) - the second covers a similar scenario, but with multigraphs.

This LGTM but should get another pair of eyes. Thanks @kalkoen !

Copy link
Member

@dschult dschult left a comment

Choose a reason for hiding this comment

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

Thanks @kalkoen and @rossbar
This looks good to me!

@dschult dschult merged commit b7816af into networkx:main Mar 10, 2024
42 of 44 checks passed
@jarrodmillman jarrodmillman added this to the 3.3 milestone Mar 10, 2024
cvanelteren pushed a commit to cvanelteren/networkx that referenced this pull request Apr 22, 2024
* Fix custom weight attribute for Mehlhorn

Using a custom weight attribute in the Mehlhorn implementation gave a KeyError. Reason: Edges in G_1_prime are given "weight" attributes, but upon updating, the weight (=/= "weight") of the existing edge in G_1_prime is get. Fix: set and get only "weight" attributes for G_1_prime.

* Add test for non-default edge attr weight.

* TST: parametrize on steiner method.

* Add test for multigraph with non-default edge attr.

---------

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
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

5 participants