Skip to content

11 bfs - #110

Open
eriknw wants to merge 1 commit into
python-graphblas:10-centralityfrom
eriknw:11-bfs
Open

11 bfs#110
eriknw wants to merge 1 commit into
python-graphblas:10-centralityfrom
eriknw:11-bfs

Conversation

@eriknw

@eriknw eriknw commented Dec 2, 2026

Copy link
Copy Markdown
Member

Add breadth-first edge and successor generators. The nodes at each depth match NetworkX's; the tree can differ because a matrix does not keep edge insertion order.

  • bfs_edges
  • bfs_successors
  • sort_neighbors is declined
  • The tree, and the order of edges within a level, can differ from NetworkX's

Stacked on #109.

A graph has many breadth-first trees. NetworkX's gives a node the
parent that reached it first, walking each node's edges in the order
they were added, and a matrix does not keep that order. These walk one
level at a time, and min_first over a frontier holding each node's own
index gives a newly reached node its neighbor on the level above that
comes first in node order. Each level is yielded by parent and then by
child, so the nodes at each depth are NetworkX's while the tree, and
the order within a level, can differ. The backend's notes for both
names say so.

sort_neighbors is declined, so NetworkX answers it: the order of each
node's neighbors is what picks NetworkX's tree. bfs_successors yields
(source, []) for a source with no children, as NetworkX does, and an
absent source raises NetworkX's error on the first step.
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.28%. Comparing base (71b0ad1) to head (15f32a6).

Additional details and impacted files
@@                Coverage Diff                @@
##           10-centrality     #110      +/-   ##
=================================================
+ Coverage          90.07%   90.28%   +0.21%     
=================================================
  Files                154      154              
  Lines               8078     8259     +181     
  Branches            1040     1054      +14     
=================================================
+ Hits                7276     7457     +181     
  Misses               557      557              
  Partials             245      245              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant