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

Helper function to avoid duplicated code when using weights #32723

Closed
dcoudert opened this issue Oct 19, 2021 · 7 comments
Closed

Helper function to avoid duplicated code when using weights #32723

dcoudert opened this issue Oct 19, 2021 · 7 comments

Comments

@dcoudert
Copy link
Contributor

Many functions with parameters by_weight and weight_function have duplicated code for checking the parameters and setting the weight function. Here we add a helper function _get_weight_function that takes all related parameters as input and return proper values for parameter by_weight and a valid weight function.

A next step will be to unify the usage of weights in graphs, as proposed in #13112, since we use either use_edge_labels or the combination of by_weight and weight_function.

CC: @tscrim

Component: graph theory

Author: David Coudert

Branch/Commit: 6800b36

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/32723

@dcoudert dcoudert added this to the sage-9.5 milestone Oct 19, 2021
@dcoudert
Copy link
Contributor Author

Branch: public/graphs/32723_weight

@dcoudert
Copy link
Contributor Author

comment:1

As soon as we agree on this method, we will use it in more methods.


New commits:

6800b36trac #32723: add method _get_weight_function and show usage

@dcoudert
Copy link
Contributor Author

Commit: 6800b36

@dcoudert dcoudert changed the title Helper function for weight functions Helper function to avoid duplicated code when using weights Oct 19, 2021
@tscrim
Copy link
Collaborator

tscrim commented Oct 20, 2021

comment:2

LGTM.

@tscrim
Copy link
Collaborator

tscrim commented Oct 20, 2021

Reviewer: Travis Scrimshaw

@dcoudert
Copy link
Contributor Author

comment:3

Thank you !

@vbraun
Copy link
Member

vbraun commented Oct 23, 2021

Changed branch from public/graphs/32723_weight to 6800b36

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

No branches or pull requests

3 participants