Skip to content

perf(graph): optimize BFS in findConnectedGraph#245

Merged
jamieshorten merged 1 commit into
accordproject:mainfrom
muhabdulkadir:moh/perf
Jun 8, 2026
Merged

perf(graph): optimize BFS in findConnectedGraph#245
jamieshorten merged 1 commit into
accordproject:mainfrom
muhabdulkadir:moh/perf

Conversation

@muhabdulkadir

@muhabdulkadir muhabdulkadir commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Closes #

Optimize the BFS traversal in DirectedGraph.findConnectedGraph to eliminate O(n) array re-indexing on each iteration.

Changes

  • Replace Array.shift() with an index pointer for O(1) dequeue
  • Replace plain object visited map with Set to avoid prototype collisions
  • Replace forEach with for-loops to avoid per-iteration closure allocation

Flags

  • No API or behavioral changes; purely internal performance improvement

Screenshots or Video

Related Issues

  • Issue #
  • Pull Request #

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Signed-off-by: muhammed-abdulkadir <muhammed.abdulkadir@docusign.com>
@jamieshorten jamieshorten merged commit 3904b17 into accordproject:main Jun 8, 2026
11 checks passed
@muhabdulkadir muhabdulkadir deleted the moh/perf branch June 8, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants