Feat: support adding multiple nodes/branches at once (performance increase) #31
+106
−56
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.
rustworkx
supports adding multiple nodes/branches at once. This is much faster than one by one.I've updated the code to support this.
benefits
This should also increase performance of methods like
Graph.from_arrays
andGrid.from_cache
side-effects
this introduces some breaking changes since some methods on the
BaseGraphModel
have been renamed:add_node
->add_node_array
add_branch
->add_branch_array
add_branch3
->add_branch3_array
On the other hand, I don't expect this to break many in existing projects, because in general the
Graph.add_branch
andGraph.add_node
functions are not directly used (e.g.,Grid.append
andGrid.add_node
are used instead)ToDo:
Performance comparison
Existing code (main):
New code: