Skip to content

Conversation

alessio-locatelli
Copy link
Contributor

@alessio-locatelli alessio-locatelli commented Mar 28, 2025

The inability to find the desired index in the subgraph was unexpected. This behavior, if it is a feature rather than a bug, needs to be documented.

@CLAassistant
Copy link

CLAassistant commented Mar 28, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coveralls
Copy link

coveralls commented Mar 28, 2025

Pull Request Test Coverage Report for Build 14141348870

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.329%

Totals Coverage Status
Change from base Build 14096559980: 0.0%
Covered Lines: 18490
Relevant Lines: 19396

💛 - Coveralls

@IvanIsCoding
Copy link
Collaborator

IvanIsCoding commented Mar 29, 2025

@mtreinish wrote this function originally. I haven't asked him but I can explain a line of reasoning for this behavior.

StableGraph behind the scenes is backed by two Vec entries in petgraph a couple of layers down. This means that for us to preserve the indexes of a graph with N nodes, we'd need roughly O(N) space.

For subgraphs, if you create many subgraphs of size k with k < N, this would be a waste of memory and performance. Therefore, Matthew implemented this function rewriting the indexes. That way, the space is O(k).

Let's document that the indices are not preserved, but the behavior is intended.

@IvanIsCoding IvanIsCoding enabled auto-merge March 29, 2025 02:38
@IvanIsCoding IvanIsCoding added this pull request to the merge queue Mar 29, 2025
Merged via the queue into Qiskit:main with commit 4baef30 Mar 29, 2025
31 checks passed
SILIZ4 pushed a commit to SILIZ4/rustworkx that referenced this pull request Jul 4, 2025
* docs: add a note that subgraph recreates indexes

* Update src/digraph.rs

---------

Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
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.

4 participants