iqm.benchmarks.utils.random_hamiltonian_path

iqm.benchmarks.utils.random_hamiltonian_path#

iqm.benchmarks.utils.random_hamiltonian_path(G: Graph, N: int) List[Tuple[int, int]]#

Generates a random Hamiltonian path with N vertices from a given NetworkX graph.

Parameters:
  • G (networkx.Graph) – The input graph.

  • N (int) – The desired number of vertices in the Hamiltonian path.

Returns:

A list of edges (tuples of nodes) representing the Hamiltonian path, or an empty list if not possible.

Return type:

list