Skip to content

Improve connectivity code#49

Merged
Ectras merged 9 commits into
mainfrom
improve_architecture_code
Aug 31, 2025
Merged

Improve connectivity code#49
Ectras merged 9 commits into
mainfrom
improve_architecture_code

Conversation

@Ectras

@Ectras Ectras commented Aug 27, 2025

Copy link
Copy Markdown
Collaborator

Various small changes in the Connectivity implementation. See the commit messages for details.

Ectras added 9 commits August 26, 2025 12:41
If nr_qubits = 0, the subtraction will wrap around and we get a panic
because a Vec of usize::MAX can not be allocated. By changing to
1..nr_qubits the range will be empty if nr_qubits = 0 and hence edges
will be [] without problems (and the i - 1 in the closure is also fine
because i >= 1).
The code
while u != v {
   if let Some(x) = ... {

   }
}
will run forever if a None is encountered at a point. Breaking in that
case doesn't make sense because we are returning a partial path without
warning. Since we already checked that self.prev[u][v] is not None, we
expect there exists a path from u to v and, hence, self.prev should also
contain all nodes along this path.
Iterating over nodes seems to be the safer option in presence of removed
nodes which could leave gaps in the node ids.
contains() and retain() were two passes over the array, pos() and
swap_remove() only take one. Since we don't use the nodes afterwards
(except for error reporting), order need not be preserved.

@Aerylia Aerylia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@Ectras Ectras merged commit ed7d240 into main Aug 31, 2025
2 checks passed
@Ectras Ectras deleted the improve_architecture_code branch August 31, 2025 20:54
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.

2 participants