Skip to content

BUG: SpanningTreeIterator raises on next #8563

Closed

Description

@rossbar

Current Behavior

Trying to extract only a single spanning tree from SpanningTreeIterator results in an
AttributeError:

>>> G = nx.cycle_graph(3)
>>> spanning_trees = nx.SpanningTreeIterator(G)
>>> next(spanning_trees)
Traceback (most recent call last)
   ...
AttributeError: 'SpanningTreeIterator' object has no attribute 'partition_queue'

Expected Behavior

Calling next on the iterator should give the next spanning tree

Environment

Python version: 3.14
NetworkX version: 802c0a2

Additional context

The class is structured such that the partition_queue isn't initialized in the constructor, but in __iter__. It should (hopefully) be a relatively simple refactor to move the queue initialization into the constructor instead.

Ran into this while reviewing #8556

Activity

  1. added a commit that references this issue on Mar 14, 2026
    87e89ae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions