GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Keep nodes without edges in to_networkx by eriknw · Pull Request #646 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

to_networkx built its DiGraph from the entries alone, so a node with no edges
vanished, and the nodes came out in the order the sorted entries named them. A
5x5 matrix with entries (0, 3), (2, 0), (3, 3) gave nodes [0, 3, 2] and
round-tripped to a permuted 3x3. It now adds range(nrows) first. viz.draw
shows such nodes too, and the user guide's line on to_networkx says what the
nodes are.

Making every row a node cannot work for a Matrix with huge dimensions, such as a
hypersparse 260 x 260 one (a DiGraph spends about 350 bytes on each node).
create_isolates=False makes nodes only of the indices that have entries, still
in index order. With the default create_isolates=True, more than 2**40 rows
raise ValueError naming the keyword instead of running out of memory.

Behavior changes:

  • Nodes with no edges are in the graph by default.
  • A non-square Matrix raises ValueError. It used to give a graph that mixed row
    and column indices; the docstring already asked for a square Matrix.

Closes #475. Supersedes #476, whose create_isolates keyword this adopts
(Sultan Orazbayev is credited as co-author).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eriknw
eriknw added this pull request to stack #650 October 19, 2026 07:50
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 685493e to 2a59411 Compare October 19, 2026 07:55
@codecov

codecov Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.76%. Comparing base (db36c4c) to head (528a65e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #646      +/-   ##
==========================================
+ Coverage   98.29%   98.76%   +0.47%     
==========================================
  Files         105      105              
  Lines       31268    31315      +47     
  Branches     3657     3661       +4     
==========================================
+ Hits        30735    30929     +194     
+ Misses        371      245     -126     
+ Partials      162      141      -21     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 2a59411 to 26e29bc Compare October 20, 2026 22:28
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 26e29bc to 0e6d3b6 Compare October 21, 2026 04:14
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 0e6d3b6 to 0901634 Compare October 21, 2026 08:38
@eriknw
eriknw removed this pull request from stack #650 October 28, 2026 04:29
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 0901634 to 869ab7d Compare October 28, 2026 04:29
@eriknw
eriknw added this pull request to stack #653 October 28, 2026 04:30
@eriknw
eriknw removed this pull request from stack #653 October 28, 2026 04:31
@eriknw
eriknw added this pull request to stack #655 October 28, 2026 04:32
@eriknw
eriknw removed this pull request from stack #655 October 28, 2026 04:33
@eriknw
eriknw added this pull request to stack #657 October 28, 2026 04:33
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 869ab7d to 55f6469 Compare October 28, 2026 13:21
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 55f6469 to 37b4eb4 Compare October 29, 2026 02:01
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 37b4eb4 to 47d8398 Compare November 3, 2026 05:53
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 47d8398 to 2b63c3f Compare November 3, 2026 12:10
@eriknw
eriknw removed this pull request from stack #657 November 3, 2026 16:44
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 2b63c3f to 7dedb5b Compare November 3, 2026 16:44
@eriknw
eriknw added this pull request to stack #660 November 3, 2026 16:45
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch 4 times, most recently from ba1e745 to cc40fd5 Compare November 10, 2026 16:47
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch 15 times, most recently from 7f6b5a2 to 710623a Compare November 11, 2026 05:42
@eriknw
eriknw removed this pull request from stack #666 November 12, 2026 06:13
@eriknw
eriknw changed the base branch from 42-networkx-structural-ingest to main November 12, 2026 06:14
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from 710623a to a239ab6 Compare November 12, 2026 06:15
@eriknw
eriknw changed the base branch from main to 29-io-config-coverage November 12, 2026 06:16
@eriknw
eriknw added this pull request to stack #670 November 12, 2026 06:17
Base automatically changed from 29-io-config-coverage to main November 12, 2026 17:09
@eriknw
Keep nodes without edges in to_networkx
3de7549
to_networkx built its DiGraph from the matrix's entries alone, so an
index whose row and column are both empty (a node with no edges)
vanished, and the nodes came out in the order the sorted entries first
named them. A 5x5 matrix with entries (0, 3), (2, 0) and (3, 3) became
a graph with nodes [0, 3, 2]; from_networkx then gave back a 3x3 matrix
with rows and columns permuted. viz.draw, which draws through to_networkx, left
such nodes out of the picture.

Add range(nrows) as nodes before the edges, so every row is a node and
the nodes iterate in index order, and from_networkx(to_networkx(M))
gives back M. The user guide's line on to_networkx said it always
labels the values "weight"; it now says what the nodes are and that
edge_attribute names (or drops) the values.
@eriknw
eriknw force-pushed the 43-networkx-to-networkx-nodes branch from a239ab6 to 3de7549 Compare November 12, 2026 17:10
@eriknw @SultanOrazbayev
Add create_isolates to to_networkx and require a square Matrix
528a65e
Making every row a node cannot work for a Matrix with huge dimensions:
for a 2**60 x 2**60 hypersparse Matrix, to_networkx would run out of
memory adding nodes (a DiGraph spends about 350 bytes on each).

create_isolates=False, from #476, makes nodes only of the indices that
have entries. They are still added in index order, so from_networkx
gives back the Matrix without its empty rows and columns. With the
default create_isolates=True, more than 2**40 rows raise ValueError
naming the keyword instead of exhausting memory; a graph that large
could never be built.

Behavior change: a non-square Matrix raises ValueError. Row i and
column i are both node i, which needs a square Matrix; a non-square one
gave a graph that mixed row and column indices. The docstring already
asked for a square Matrix.

Co-authored-by: Sultan Orazbayev <[email protected]>
@eriknw

eriknw commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

LGTM.

@SultanOrazbayev, this pulls in the keyword you added in #476, but defaults to True instead. Sorry I let that PR linger! Things got busy. Thanks for the contribution

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[pyos][io] Conversion to NetworkX drops isolated vertices

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@eriknw
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.