-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
non recursive version of method gomory_hu_tree
for graphs
#38791
Merged
vbraun
merged 4 commits into
sagemath:develop
from
dcoudert:graphs/non_recursive_gomory_hu_tree
Nov 16, 2024
Merged
non recursive version of method gomory_hu_tree
for graphs
#38791
vbraun
merged 4 commits into
sagemath:develop
from
dcoudert:graphs/non_recursive_gomory_hu_tree
Nov 16, 2024
Conversation
This file contains 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
Documentation preview for this PR (built with commit b844daa; changes) is ready! 🎉 |
@maxale, this is ready to be reviewed. |
I'm slow to respond in the coming few days. We've just moved Oxford U. -> Northwestern U. |
dimpase
approved these changes
Nov 7, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Nov 8, 2024
…r graphs This PR implements a non recursive version of method `gomory_hu_tree` for graphs. This fixes the max recursion depth error reported in https://ask.sagemath.org/question/79577/graphs-gomory-hu-tree-memory- blow-up-and-max-recursion-depth/. The memory consumption is seriously reduced. Without this PR: ```py sage: def test(g): ....: from datetime import datetime ....: import psutil ....: start_time = datetime.now() ....: process = psutil.Process(os.getpid()) ....: mem = process.memory_info()[0] / float(2 ** 20) ....: print("Mem usage at start:", mem, "MiB") ....: try: ....: print("Vertices found:", g.order(), "and edges:", g.size()) ....: T = g.gomory_hu_tree(algorithm="FF") ....: except Exception as error: ....: print("Error detected:", error) ....: finally: ....: end_time = datetime.now() ....: print("Runtime =", end_time - start_time) ....: mem = process.memory_info()[0] / float(2 ** 20) ....: print("Mem usage at end:", mem, "MiB") ....: sage: test(graphs.SierpinskiGasketGraph(5)) Mem usage at start: 241.0234375 MiB Vertices found: 123 and edges: 243 Runtime = 0:00:00.243477 Mem usage at end: 252.1171875 MiB sage: test(graphs.SierpinskiGasketGraph(6)) Mem usage at start: 252.1171875 MiB Vertices found: 366 and edges: 729 Runtime = 0:00:02.050924 Mem usage at end: 324.30078125 MiB sage: test(graphs.SierpinskiGasketGraph(7)) Mem usage at start: 324.30078125 MiB Vertices found: 1095 and edges: 2187 Runtime = 0:00:21.207451 Mem usage at end: 968.97265625 MiB sage: test(graphs.SierpinskiGasketGraph(8)) Mem usage at start: 950.25390625 MiB Vertices found: 3282 and edges: 6561 Error detected: maximum recursion depth exceeded Runtime = 0:04:36.154550 Mem usage at end: 6767.39453125 MiB ``` With this PR ```py sage: test(graphs.SierpinskiGasketGraph(5)) Mem usage at start: 246.0859375 MiB Vertices found: 123 and edges: 243 Runtime = 0:00:00.219925 Mem usage at end: 246.7109375 MiB sage: test(graphs.SierpinskiGasketGraph(6)) Mem usage at start: 247.0234375 MiB Vertices found: 366 and edges: 729 Runtime = 0:00:01.900761 Mem usage at end: 248.2734375 MiB sage: test(graphs.SierpinskiGasketGraph(7)) Mem usage at start: 248.5859375 MiB Vertices found: 1095 and edges: 2187 Runtime = 0:00:18.535145 Mem usage at end: 252.4921875 MiB sage: test(graphs.SierpinskiGasketGraph(8)) Mem usage at start: 253.1171875 MiB Vertices found: 3282 and edges: 6561 Runtime = 0:02:57.325506 Mem usage at end: 265.15234375 MiB sage: test(graphs.SierpinskiGasketGraph(9)) Mem usage at start: 263.625 MiB Vertices found: 9843 and edges: 19683 Runtime = 0:29:03.321870 Mem usage at end: 296.8359375 MiB sage: test(graphs.SierpinskiGasketGraph(10)) Mem usage at start: 303.11328125 MiB Vertices found: 29526 and edges: 59049 Runtime = 5:01:45.355463 Mem usage at end: 399.3984375 MiB ``` ### :memo: Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### :hourglass: Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38791 Reported by: David Coudert Reviewer(s): Dima Pasechnik
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Nov 9, 2024
…r graphs This PR implements a non recursive version of method `gomory_hu_tree` for graphs. This fixes the max recursion depth error reported in https://ask.sagemath.org/question/79577/graphs-gomory-hu-tree-memory- blow-up-and-max-recursion-depth/. The memory consumption is seriously reduced. Without this PR: ```py sage: def test(g): ....: from datetime import datetime ....: import psutil ....: start_time = datetime.now() ....: process = psutil.Process(os.getpid()) ....: mem = process.memory_info()[0] / float(2 ** 20) ....: print("Mem usage at start:", mem, "MiB") ....: try: ....: print("Vertices found:", g.order(), "and edges:", g.size()) ....: T = g.gomory_hu_tree(algorithm="FF") ....: except Exception as error: ....: print("Error detected:", error) ....: finally: ....: end_time = datetime.now() ....: print("Runtime =", end_time - start_time) ....: mem = process.memory_info()[0] / float(2 ** 20) ....: print("Mem usage at end:", mem, "MiB") ....: sage: test(graphs.SierpinskiGasketGraph(5)) Mem usage at start: 241.0234375 MiB Vertices found: 123 and edges: 243 Runtime = 0:00:00.243477 Mem usage at end: 252.1171875 MiB sage: test(graphs.SierpinskiGasketGraph(6)) Mem usage at start: 252.1171875 MiB Vertices found: 366 and edges: 729 Runtime = 0:00:02.050924 Mem usage at end: 324.30078125 MiB sage: test(graphs.SierpinskiGasketGraph(7)) Mem usage at start: 324.30078125 MiB Vertices found: 1095 and edges: 2187 Runtime = 0:00:21.207451 Mem usage at end: 968.97265625 MiB sage: test(graphs.SierpinskiGasketGraph(8)) Mem usage at start: 950.25390625 MiB Vertices found: 3282 and edges: 6561 Error detected: maximum recursion depth exceeded Runtime = 0:04:36.154550 Mem usage at end: 6767.39453125 MiB ``` With this PR ```py sage: test(graphs.SierpinskiGasketGraph(5)) Mem usage at start: 246.0859375 MiB Vertices found: 123 and edges: 243 Runtime = 0:00:00.219925 Mem usage at end: 246.7109375 MiB sage: test(graphs.SierpinskiGasketGraph(6)) Mem usage at start: 247.0234375 MiB Vertices found: 366 and edges: 729 Runtime = 0:00:01.900761 Mem usage at end: 248.2734375 MiB sage: test(graphs.SierpinskiGasketGraph(7)) Mem usage at start: 248.5859375 MiB Vertices found: 1095 and edges: 2187 Runtime = 0:00:18.535145 Mem usage at end: 252.4921875 MiB sage: test(graphs.SierpinskiGasketGraph(8)) Mem usage at start: 253.1171875 MiB Vertices found: 3282 and edges: 6561 Runtime = 0:02:57.325506 Mem usage at end: 265.15234375 MiB sage: test(graphs.SierpinskiGasketGraph(9)) Mem usage at start: 263.625 MiB Vertices found: 9843 and edges: 19683 Runtime = 0:29:03.321870 Mem usage at end: 296.8359375 MiB sage: test(graphs.SierpinskiGasketGraph(10)) Mem usage at start: 303.11328125 MiB Vertices found: 29526 and edges: 59049 Runtime = 5:01:45.355463 Mem usage at end: 399.3984375 MiB ``` ### :memo: Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### :hourglass: Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38791 Reported by: David Coudert Reviewer(s): Dima Pasechnik
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Nov 13, 2024
…r graphs This PR implements a non recursive version of method `gomory_hu_tree` for graphs. This fixes the max recursion depth error reported in https://ask.sagemath.org/question/79577/graphs-gomory-hu-tree-memory- blow-up-and-max-recursion-depth/. The memory consumption is seriously reduced. Without this PR: ```py sage: def test(g): ....: from datetime import datetime ....: import psutil ....: start_time = datetime.now() ....: process = psutil.Process(os.getpid()) ....: mem = process.memory_info()[0] / float(2 ** 20) ....: print("Mem usage at start:", mem, "MiB") ....: try: ....: print("Vertices found:", g.order(), "and edges:", g.size()) ....: T = g.gomory_hu_tree(algorithm="FF") ....: except Exception as error: ....: print("Error detected:", error) ....: finally: ....: end_time = datetime.now() ....: print("Runtime =", end_time - start_time) ....: mem = process.memory_info()[0] / float(2 ** 20) ....: print("Mem usage at end:", mem, "MiB") ....: sage: test(graphs.SierpinskiGasketGraph(5)) Mem usage at start: 241.0234375 MiB Vertices found: 123 and edges: 243 Runtime = 0:00:00.243477 Mem usage at end: 252.1171875 MiB sage: test(graphs.SierpinskiGasketGraph(6)) Mem usage at start: 252.1171875 MiB Vertices found: 366 and edges: 729 Runtime = 0:00:02.050924 Mem usage at end: 324.30078125 MiB sage: test(graphs.SierpinskiGasketGraph(7)) Mem usage at start: 324.30078125 MiB Vertices found: 1095 and edges: 2187 Runtime = 0:00:21.207451 Mem usage at end: 968.97265625 MiB sage: test(graphs.SierpinskiGasketGraph(8)) Mem usage at start: 950.25390625 MiB Vertices found: 3282 and edges: 6561 Error detected: maximum recursion depth exceeded Runtime = 0:04:36.154550 Mem usage at end: 6767.39453125 MiB ``` With this PR ```py sage: test(graphs.SierpinskiGasketGraph(5)) Mem usage at start: 246.0859375 MiB Vertices found: 123 and edges: 243 Runtime = 0:00:00.219925 Mem usage at end: 246.7109375 MiB sage: test(graphs.SierpinskiGasketGraph(6)) Mem usage at start: 247.0234375 MiB Vertices found: 366 and edges: 729 Runtime = 0:00:01.900761 Mem usage at end: 248.2734375 MiB sage: test(graphs.SierpinskiGasketGraph(7)) Mem usage at start: 248.5859375 MiB Vertices found: 1095 and edges: 2187 Runtime = 0:00:18.535145 Mem usage at end: 252.4921875 MiB sage: test(graphs.SierpinskiGasketGraph(8)) Mem usage at start: 253.1171875 MiB Vertices found: 3282 and edges: 6561 Runtime = 0:02:57.325506 Mem usage at end: 265.15234375 MiB sage: test(graphs.SierpinskiGasketGraph(9)) Mem usage at start: 263.625 MiB Vertices found: 9843 and edges: 19683 Runtime = 0:29:03.321870 Mem usage at end: 296.8359375 MiB sage: test(graphs.SierpinskiGasketGraph(10)) Mem usage at start: 303.11328125 MiB Vertices found: 29526 and edges: 59049 Runtime = 5:01:45.355463 Mem usage at end: 399.3984375 MiB ``` ### :memo: Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### :hourglass: Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38791 Reported by: David Coudert Reviewer(s): Dima Pasechnik
5 tasks
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.
This PR implements a non recursive version of method
gomory_hu_tree
for graphs. This fixes the max recursion depth error reported in https://ask.sagemath.org/question/79577/graphs-gomory-hu-tree-memory-blow-up-and-max-recursion-depth/. The memory consumption is seriously reduced.Without this PR:
With this PR
📝 Checklist
⌛ Dependencies