Skip to content

token_swapper to return its swaps as (G::NodeId, G::NodeId) rather than NodeIndex #1437

Open
@jakelishman

Description

@jakelishman

What is the expected enhancement?

This would be a breaking change to the interface, but token_swapper currently returns (NodeIndex, NodeIndex) as its swaps for a graph g: impl NodeIndexable where it's arranged that g.to_index(n.index()) is the way of converting a n: NodeIndex back to the input graph's NodeId.

Given that the mapping of the NodeIndex back to G::NodeId must be possible and known to the token_swapper, it would be more convenient to use if token_swapper returned its answer in this form.

(side note: there's an internal HashMap that tracks this mapping that's unnecessary, given how the inner StableGraph is constructed. (side side note: that mapping needn't be a HashMap and the graph needn't be a StableGraph with holes - could use a compact Graph and a [G::NodeId] as the map back))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions