formachines / errata

Errata / PyPI / networkx

random_lobster removed in networkx 3.7

In our sandbox runs up to 2026-10-27, claude-sonnet-5-5, gemini-3.8-flash and gpt-6.1-sol wrote G = nx.random_lobster(n, p1, p2, seed=seed) for networkx. It fails on 3.7 with AttributeError (changed between 3.6.1 and 3.7). Use G = nx.random_lobster_graph(n, p1, p2, seed=seed) instead.

What to do
replace the line
Output
same on one example
Patch
applies word for word
Auto-apply
allowed
Seen in
3 models
Worked / failed
6 / 0
Last verified
2026-10-27

What to do

Replace the old line with the new one; the rest of the code can stay.

Automatic application: allowed — proof.equivalent is true and the patch applies word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (removed); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Old and new code

G = nx.random_lobster(n, p1, p2, seed=seed)
G = nx.random_lobster_graph(n, p1, p2, seed=seed)

Error on 3.7:

AttributeError: module 'networkx' has no attribute 'random_lobster'
Sandbox proof
Scriptnetworkx versionResult
Code the models wrote3.6.1works
Code the models wrote3.7fails: AttributeError
Verified example below3.7works
Output of the verified example3.7same as the original's on 3.6.1 (observed stdout of one example; not a proof of equivalent behaviour)
Patch applied word for word to the example3.7applied word for word, the patch parses, runs and prints what the verified example prints

Verified example for networkx 3.7

import networkx as nx

# Note: in networkx, `n` is the *expected* number of backbone nodes;
# the actual backbone length is drawn randomly around this value.
n = 20
p1 = 0.9  # probability of adding an edge at the first level (backbone -> leaf)
p2 = 0.9  # probability of adding an edge at the second level (leaf -> leaf)
seed = 42

G = nx.random_lobster_graph(n, p1, p2, seed=seed)

num_nodes = G.number_of_nodes()
num_edges = G.number_of_edges()

try:
    is_tree = nx.is_tree(G)
except nx.NetworkXPointlessConcept:
    # Raised for the null graph (no nodes)
    is_tree = False

print(f"Number of nodes: {num_nodes}")
print(f"Number of edges: {num_edges}")
print(f"Is a tree: {is_tree}")

Source

Expire random lobster dep ([#8499](https://github.com/networkx/networkx/pull/8499)).

Release notes · Seen in: claude-sonnet-5-5, gemini-3.8-flash, gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for networkx

For agents