dwave.graphs.algorithms.automorphism.sample_automorphisms#

sample_automorphisms(u_vector: list[list[NDArray[int64]]], num_samples: int = 1, seed: int | None = None, num_nodes: int | None = None) list[NDArray[int64]][source]#

Uniformly sample automorphisms from the Schreier-Sims representation.

Randomly samples one coset representative from each non-trivial left transversal and takes the product, guaranteeing uniform sampling. The automorphisms can be composed uniformly regardless of the ordering of the left transversals in ‘u_vector’. All products involving identity automorphisms are ignored.

Parameters:
  • u_vector – Coset representatives grouped by stabilizer index.

  • num_samples – The number of automorphisms to return.

  • seed – Random seed for reproducibility.

  • num_nodes – The number of nodes in the graph. If not provided, it is inferred from the length of the first coset representative in u_vector.

Returns:

A list of uniformly sampled automorphisms in one-line notation.

Example

>>> import networkx as nx
>>> from dwave.graphs.algorithms.automorphism import schreier_rep, sample_automorphisms
...
>>> graph = nx.cycle_graph(8)
>>> result = schreier_rep(graph)
>>> sample_automorphisms(result.u_vector, seed=42)
[array([3, 4, 5, 6, 7, 0, 1, 2])]
>>> sample_automorphisms(result.u_vector, num_samples=2, seed=42)
[array([3, 4, 5, 6, 7, 0, 1, 2]), array([6, 5, 4, 3, 2, 1, 0, 7])]