Skip to content

Fix TSP weight parameter issues - #7721

Merged
mjschwenne merged 1 commit into
networkx:mainfrom
mjschwenne:fix-7720
Nov 18, 2024
Merged

mjschwenne merged 1 commit into
networkx:mainfrom
mjschwenne:fix-7720

Conversation

@mjschwenne

Copy link
Copy Markdown
Contributor

Fixes #7720. See that issue for a description of the issue and solution.

@Schefflera-Arboricola Schefflera-Arboricola left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @mjschwenne :)

I think the purpose of the test added here might be more clear if instead of having the "distance" attribute we don't have any attribute. But, I think it's fine this way also. Thanks!

@mjschwenne

Copy link
Copy Markdown
Contributor Author

When the provided attribute isn't on the edges, the algorithms will assume an edge weight of 1 for all the edges (which is what it's already doing for the 'unweighted' edges in the complete graphs). If we didn't put non-one edge weights on each graph, passing in a different value for the weight parameter wouldn't be able to differentiate between the graphs since we'd fallback to the implicit edge weights.

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!
Thanks @dt99jay for reporting it! And @mjschwenne for the quick fix!

@mjschwenne
mjschwenne merged commit 9c5ca54 into networkx:main Nov 18, 2024
@jarrodmillman jarrodmillman added this to the 3.5 milestone Nov 18, 2024
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.

traveling_salesman_problem seems to ignore the weight parameter

5 participants