rustworkx.connected_subgraphs#

connected_subgraphs(graph, k, /)#

Return all the connected subgraphs (as a list of node indices) with exactly k nodes

Parameters:
  • graph (PyGraph) – The graph to find all connected subgraphs in

  • k (int) – The maximum number of nodes in a returned connected subgraph.

Returns:

A list of connected subgraphs with k nodes, represented by their node indices

Raises:

ValueError – If k is larger than the number of nodes in graph