Skip to content

Conversation

Thijss
Copy link
Contributor

@Thijss Thijss commented Feb 4, 2025

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

Should increase performance of methods like Graph.from_arrays and Grid.from_cache

side-effects

Introduces some breaking changes as 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 much in existing projects, because in general the Graph.add_branch and Graph.add_node functions are not directly used (e.g., Grid.append and Grid.add_node are used instead)

Performance comparison

Existing code (main):
ExistingCode

New code:
NewCode

Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
@Thijss Thijss changed the title Feat/improve performance creating large graphs Feat: support adding multiple nodes/branches at once (performance increase) Feb 4, 2025
Copy link

sonarqubecloud bot commented Feb 4, 2025

@Thijss Thijss marked this pull request as ready for review February 11, 2025 06:48
Copy link
Contributor

@jaapschoutenalliander jaapschoutenalliander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice performance improvement 👍, in general it looks good. I have some open questions

Thijss and others added 7 commits February 14, 2025 18:03
Signed-off-by: jaapschoutenalliander <[email protected]>
DCO Remediation Commit for Thijs Baaijen <[email protected]>

I, Thijs Baaijen <[email protected]>, hereby add my Signed-off-by to this commit: b1601a8
I, Thijs Baaijen <[email protected]>, hereby add my Signed-off-by to this commit: 0598eb8
I, Thijs Baaijen <[email protected]>, hereby add my Signed-off-by to this commit: 82d52f9

Signed-off-by: Thijs Baaijen <[email protected]>
Copy link

Signed-off-by: Thijs Baaijen <[email protected]>
Copy link

@Thijss Thijss merged commit 3ab9816 into main Apr 18, 2025
19 checks passed
@Thijss Thijss deleted the feat/improve-performance-creating-large-graphs branch April 18, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants