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

Inefficiency with UndirectedSpanningTree method for a mutable digraph #581

Open
wilfwilson opened this issue Apr 23, 2023 · 0 comments
Open
Labels
difficulty: 0 A label for feature requests that should be easy help wanted A label for issues or PRs where help is wanted newcomer-friendly A label for issues that someone thought might be friendly newcomers. performance A label for issues or PR related to performance

Comments

@wilfwilson
Copy link
Collaborator

The method for UndirectedSpanningTree for IsMutableDigraph creates two undirected spanning forests, but it should be able to get by with creating only one:

Digraphs/gap/attr.gi

Lines 2283 to 2293 in 119adb3

InstallMethod(UndirectedSpanningTree, "for a mutable digraph",
[IsMutableDigraph],
function(D)
if not (DigraphHasAVertex(D)
and IsStronglyConnectedDigraph(D)
and IsConnectedDigraph(UndirectedSpanningForest(DigraphMutableCopy(D))))
then
return fail;
fi;
return UndirectedSpanningForest(D);
end);

Specifically, an undirected spanning tree is created as part of the big if statement, and then again at the end.

I believe that eliminating this inefficiency would need only a simple refactoring and should be an doable for a newcomer to Digraphs.

@wilfwilson wilfwilson added help wanted A label for issues or PRs where help is wanted performance A label for issues or PR related to performance difficulty: 0 A label for feature requests that should be easy newcomer-friendly A label for issues that someone thought might be friendly newcomers. labels Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 0 A label for feature requests that should be easy help wanted A label for issues or PRs where help is wanted newcomer-friendly A label for issues that someone thought might be friendly newcomers. performance A label for issues or PR related to performance
Projects
None yet
Development

No branches or pull requests

1 participant