Skip to content

Preserve isolated nodes in Matching.to_networkx() - #197

Open
JunkaiWang-TheoPhy wants to merge 1 commit into
oscarhiggott:masterfrom
JunkaiWang-TheoPhy:fix/networkx-isolated-nodes
Open

JunkaiWang-TheoPhy wants to merge 1 commit into
oscarhiggott:masterfrom
JunkaiWang-TheoPhy:fix/networkx-isolated-nodes

Conversation

@JunkaiWang-TheoPhy

Copy link
Copy Markdown

A matching graph can contain detectors and boundary nodes without incident edges. Exporting it with to_networkx currently drops them, so reconstructing Matching from that graph changes the detector count and boundary set.

Add all real node IDs to the graph before assigning boundary attributes. Doing this after inserting edges preserves the existing edge traversal order and virtual-boundary handling.

The added round-trip test uses four nodes, a single edge, one isolated detector and one isolated boundary node. Before the change the exported graph had no isolates. Afterward the full output_graph_test.py module passed (5 tests), including the existing virtual-boundary and self-loop cases. Tested the checkout's Python code with the released native extension on CPU.

This branch has not been deployed

No deployments
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.

1 participant