dimod.utilities.child_structure_dfs

child_structure_dfs(sampler, seen=None)[source]

Return the structure of a composed sampler using a depth-first search on its children.

Parameters:
  • sampler (Sampler) – Structured or composed sampler with at least one structured child.
  • seen (set, optional, default=False) – IDs of already checked child samplers.
Returns:

A named tuple of the form Structure(nodelist, edgelist, adjacency), where the 3-tuple values are the Structured.nodelist, Structured.edgelist and Structured.adjacency attributes of the first structured sampler found.

Return type:

namedtuple

Raises:

ValueError – If no structured sampler is found.

Examples:

>>> import dimod
>>> sampler = dimod.TrackingComposite(
...                 dimod.StructureComposite(
...                 dimod.ExactSolver(), [0, 1], [(0, 1)]))
>>> print(dimod.child_structure_dfs(sampler).nodelist)
[0, 1]