Proposal for a New Function

71 views
Skip to first unread message

Pavel Stříž

unread,
Nov 30, 2025, 10:30:42 AM (3 days ago) Nov 30
to sage-devel
Hello from a newbie, and thank you for Sage and all the work you're putting into it!

I'd like to know you opinion on this.  If this seems useful for the community, I believe I can improve sage.graphs.graph_coloring.number_of_n_colorings by adding pruning during the recursion.  I'm considering the following steps:

- Start testing with Git.
- Rename the variables in my code from Czech to English.
- Add comments to the code.
- Integrate it into Sage's code structure.
- Prepare examples with results for testing and comparison.
- Write documentation, etc.

After that, I'd propose adding a new function, e.g. number_of_n_colorings_with_pruning, so that the original pure-recursive number_of_n_colorings remains unchanged.

Do you recommend a different approach?

Best regards, 
Pavel

dmo...@deductivepress.ca

unread,
Nov 30, 2025, 5:08:38 PM (2 days ago) Nov 30
to sage-devel
We do not want two different functions that do the same thing.

If your code is unequivocally better than the existing code, then it should replace the existing program. On the other hand, if both approaches have merit, then you can add an "algorithm" keyword to the existing function, which will allow the user to choose which code to use. (You can write a new private function whose name starts with an underscore. Then the main function can use the value of the algorithm parameter to decide whether to call the new function.)

Please open a github issue, so further discussion can happen there, instead of in this general thread.

kcrisman

unread,
Dec 1, 2025, 10:30:06 AM (2 days ago) Dec 1
to sage-devel
Hello from a newbie, and thank you for Sage and all the work you're putting into it!

Thanks on behalf of both the current active developers as well as those of us not so active :-) we love new developers.
 
- Start testing with Git.
- Rename the variables in my code from Czech to English.
- Add comments to the code.
- Integrate it into Sage's code structure.

Yes, we have a number of "best practices" regarding documentation, testing, etc.  See https://doc.sagemath.org/html/en/developer/ and perhaps especially the bottom of https://doc.sagemath.org/html/en/developer/coding_basics.html for these questions.
 

After that, I'd propose adding a new function, e.g. number_of_n_colorings_with_pruning, so that the original pure-recursive number_of_n_colorings remains unchanged.

As the other post suggests, one could either replace or add algorithms (we have examples of both in Sage history).  As they say, f you can put the Github issue you open for this in this thread, then people can continue to follow it there. 
Reply all
Reply to author
Forward
0 new messages