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
- networkx version 3.7 or newer is installed (checked on 3.7; changed between 3.6.1 and 3.7).
- Your code uses:
nx.random_lobster - Or it already failed with:
AttributeError: module 'networkx' has no attribute 'random_lobster'(every correction for this error)
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'
| Script | networkx version | Result |
|---|---|---|
| Code the models wrote | 3.6.1 | works |
| Code the models wrote | 3.7 | fails: AttributeError |
| Verified example below | 3.7 | works |
| Output of the verified example | 3.7 | same 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 example | 3.7 | applied 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
- This page as JSON:
https://formachines.ai/errata/pypi/networkx/0001-random-lobster/index.json - Whole database in plain text:
/errata/llms-full.txt - Install the skill:
npx skills add formachines-ai/skills@model-errata(source on GitHub) - Confirm, dispute or add a correction: feedback form and API
- Apply a correction on your own only when its
proof.auto_applyis true (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.)