python-graphblas / graphblas-algorithms

Graph algorithms written in GraphBLAS
Apache License 2.0
73 stars 4 forks source link

Add a few more BFS-based algorithms #51

Closed eriknw closed 1 year ago

eriknw commented 1 year ago

BFS is a workhorse! There are still many BFS-based algorithms still to do.

My main TODO is to benchmark these to give them a proper shakedown. I like to shake down most algorithms we add. Also, I wonder whether we should use A.T or AT in a couple places. I also wonder if we can come up with a heuristic to detect negative cycles.

It may be nice to know whether directed graphs are structurally symmetric. If we knew this, we could improve is_weakly_connected and other algorithms.

Also, there may be a couple NetworkX bugs to fix or behaviors to match.

Implemented:

eriknw commented 1 year ago

I'm also not sure if these are the best algorithms for connected component-related functions. Connected components are an important class of algorithms that we should add soon (for example, we have an implementation of FastSV in a Jupyter notebook that we can port over), so perhaps we'll revisit these algorithms then.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 87.71% and project coverage change: +2.46 :tada:

Comparison is base (6de1fd6) 69.16% compared to head (029a639) 71.62%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #51 +/- ## ========================================== + Coverage 69.16% 71.62% +2.46% ========================================== Files 77 89 +12 Lines 3152 3461 +309 Branches 602 642 +40 ========================================== + Hits 2180 2479 +299 + Misses 786 783 -3 - Partials 186 199 +13 ``` | [Impacted Files](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas) | Coverage Δ | | |---|---|---| | [graphblas\_algorithms/nxapi/\_utils.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvbnhhcGkvX3V0aWxzLnB5) | `57.47% <0.00%> (ø)` | | | [graphblas\_algorithms/nxapi/cluster.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvbnhhcGkvY2x1c3Rlci5weQ==) | `85.55% <ø> (+7.55%)` | :arrow_up: | | [graphblas\_algorithms/classes/nodeset.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvY2xhc3Nlcy9ub2Rlc2V0LnB5) | `69.44% <42.85%> (-2.20%)` | :arrow_down: | | [...as\_algorithms/algorithms/link\_analysis/hits\_alg.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvYWxnb3JpdGhtcy9saW5rX2FuYWx5c2lzL2hpdHNfYWxnLnB5) | `60.86% <50.00%> (ø)` | | | [...blas\_algorithms/nxapi/shortest\_paths/unweighted.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvbnhhcGkvc2hvcnRlc3RfcGF0aHMvdW53ZWlnaHRlZC5weQ==) | `62.50% <62.50%> (ø)` | | | [graphblas\_algorithms/classes/nodemap.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvY2xhc3Nlcy9ub2RlbWFwLnB5) | `50.67% <75.00%> (+1.70%)` | :arrow_up: | | [...s\_algorithms/algorithms/shortest\_paths/weighted.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvYWxnb3JpdGhtcy9zaG9ydGVzdF9wYXRocy93ZWlnaHRlZC5weQ==) | `31.36% <78.12%> (+11.21%)` | :arrow_up: | | [...algorithms/algorithms/shortest\_paths/unweighted.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvYWxnb3JpdGhtcy9zaG9ydGVzdF9wYXRocy91bndlaWdodGVkLnB5) | `78.57% <78.57%> (ø)` | | | [graphblas\_algorithms/algorithms/dag.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvYWxnb3JpdGhtcy9kYWcucHk=) | `94.28% <81.81%> (+0.73%)` | :arrow_up: | | [...as\_algorithms/algorithms/shortest\_paths/generic.py](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas#diff-Z3JhcGhibGFzX2FsZ29yaXRobXMvYWxnb3JpdGhtcy9zaG9ydGVzdF9wYXRocy9nZW5lcmljLnB5) | `86.66% <92.30%> (+1.48%)` | :arrow_up: | | ... and [26 more](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas) | | ... and [1 file with indirect coverage changes](https://codecov.io/gh/python-graphblas/graphblas-algorithms/pull/51/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-graphblas)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

eriknw commented 1 year ago

Merging so we can do a release before PyConUS. May be able to benchmark and shakedown some algorithms later, but they're probably good enough.