Repository navigation
SetGraphOptions looks up each element's options in a table - #11
Merged
Merged
Conversation
SetGraphOptions for vertices, and for edges with the tag All, found the options of each vertex or edge with a Position over all the groups of options: once per element, so the square of their number. SetEdgeWeights goes through it, and on a 30x30 grid graph (1740 edges) that was most of its time. Now the group of each key is entered once in a table, the DownValues of a local symbol, cleared afterwards. Groups are entered last to first, so that a key in several groups gets the first one, as Position gave. SetEdgeWeights[GridGraph[15, 15]]: 10.9 s -> 3.3 s (Mathics3 with the MATH-425 changes). The results are the same for edge and vertex options, groups with several keys, a key in several groups and keys without options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
This changes the source code (for the better, probably even on WMA). I heard from Steve Skiena a while back that it was okay to change source code. Sriram V. Pemmaraju I've never heard from even though I have tried to contact him a couple of times. |
Member
|
LGTM and thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SetGraphOptionsfor vertices, and for edges with the tagAll, found each element's options with aPositionover all the groups of options. That ran once per vertex or edge, so the cost was the square of their number.SetEdgeWeightsgoes through it, and on a 30×30 grid graph (1740 edges) it took most of the time.Change
Position[...][[1, 1]]gave.Onevariant (multigraphs, where each match is used once) is unchanged.Check: results are identical to the old version for 10 cases: edge and vertex options, groups with several keys, a key in several groups, undirected edges given in reverse order, and keys without options.
Timings (on kimmy, Mathics3 with the MATH-425 changes, mathics-core #2099–#2103):
SetEdgeWeights[GridGraph[30, 30]]MinimumSpanningTree[SetEdgeWeights[GridGraph[30, 30]]]The lookups are linear only once mathics-core finds stored values through its index again; mathics-core #2104 fixes that.
Tests: the package tests pass with
COMBINATORICA_BOOK_SECS=5: 804 passed, 0 failed. They also give 21 XPASS, because Mathics3 there already has fixes thatbook/xfail.jsonon master still marks as pending; #10 updates that file.🤖 Generated with Claude Code