-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Speed up methods allow_multiple_edges and multiple_edges #33569
Comments
comment:1
It can certainly be even faster if done in the backends, but it's already an improvement. New commits:
|
Commit: |
This comment has been minimized.
This comment has been minimized.
Branch: public/graphs/33569_speedup |
comment:3
While this is undeniably faster, this seems to be much worse in memory. The current code just needs all of the multiedges and the local information around a vertex I believe. However, the proposed code requires essentially making a copy of the graph as it needs to hold all of the edges in memory (plus a second copy for all of the keys of the One thing that could be done to make this even faster would be to use the edges = {}
multi_edges = set()
for e in self.edge_iterator(labels=labels):
f = edge_id(e[0], e[1])
if f in edges:
multi_edges.add(f)
edges[f].append(e)
else:
edges[f] = [e]
multi_edges = sum(edges[f] for f in multi_edges, []) This would save an iteration over all of the edges of the graph. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:5
I have pushed an alternative implementation of method
On the way I discovered that by default |
comment:6
Thank you. I think this is a good trade-off between CPU and memory as well. |
Reviewer: Travis Scrimshaw |
Changed branch from public/graphs/33569_speedup to |
Before (insane for large graphs)
After
CC: @kliem @tscrim
Component: graph theory
Author: David Coudert
Branch/Commit:
f3fd774
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/33569
The text was updated successfully, but these errors were encountered: