Skip to content

[networkx] Use concrete node types for the sudoku, internet AS, joint degree and spectral forge generators - #16842

Merged
srittau merged 1 commit into
python:mainfrom
dannyshafer:networkx-sudoku-internet-joint-degree-forge-node-types
Nov 16, 2026
Merged

srittau merged 1 commit into
python:mainfrom
dannyshafer:networkx-sudoku-internet-joint-degree-forge-node-types

Conversation

@dannyshafer

Copy link
Copy Markdown
Contributor

These generators all build their graphs on integer nodes, so they now return Graph[int] instead of Graph[Incomplete]:

  • sudoku_graph starts from nx.empty_graph(n**4) (sudoku.py)
  • joint_degree_graph starts from nx.empty_graph(N) (joint_degree_seq.py)
  • spectral_graph_forge returns nx.from_numpy_array(B), whatever the input node type (spectral_graph_forge.py)
  • random_internet_as_graph (and AS_graph_generator.t_graph / generate, which return the same graph) number nodes with consecutive ints (internet_as_graphs.py)

directed_joint_degree_graph builds an nx.DiGraph() (joint_degree_seq.py), so it now returns DiGraph[int].

Checked at runtime with networkx 3.6.1 that each returns the stated class with only int nodes. Locally, tests/mypy_test.py stubs/networkx, tests/stubtest_third_party.py networkx, pyright 1.1.414 on the generators directory, ruff and black all pass.

Written with Claude Code (an AI coding agent).

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit 6a467d7 into python:main Nov 16, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants