Complete Graphs.jl AbstractGraph API for IGraph#35
Complete Graphs.jl AbstractGraph API for IGraph#35nenadilic84 wants to merge 2 commits intoJuliaGraphs:masterfrom
Conversation
Implement the missing Graphs.jl interface methods so that IGraph can be used with all existing Graphs.jl algorithms: - edges: lazy IGraphEdgeIterator over igraph edge IDs - outneighbors/inneighbors: via LibIGraph.neighbors with 0→1 index shift - add_edge!: with duplicate and self-loop guards - add_vertex!: via raw igraph_add_vertices ccall - rem_vertex!: via igraph_delete_vertices with igraph_vss_1 selector - copy: via LibIGraph.copy into uninitialized IGraph Also fix has_edge to correctly convert 1-based Julia indices to 0-based igraph indices before calling get_eid. Add GraphsInterfaceChecker.jl to test dependencies and a comprehensive test suite that validates both the mandatory and optional (mutation) parts of the AbstractGraph interface. All 305 tests pass (up from 267).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
=========================================
+ Coverage 5.29% 6.37% +1.08%
=========================================
Files 8 8
Lines 4310 4342 +32
=========================================
+ Hits 228 277 +49
+ Misses 4082 4065 -17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Added CHANGELOG.md entry in the latest push. Note: several CI checks fail on this PR but they are all pre-existing issues unrelated to this PR's changes:
All actual test jobs pass on all platforms (ubuntu, macOS x64/aarch64, windows) and on Julia 1.10. |
|
/claim #446 |
|
@nenadilic84 , we are having a few related discussions in #43 (and now #45). I tagged you in #43 with a few questions / suggestions. Let me know if you are interested in pursuing them -- happy to help making sure everyone is onboarded on this project and can contribute to it. For now I will mark this PR as closed, but if you want to integrate your changes (and check out the comments in #43), we can always reopen it. |
Summary
This PR completes the
Graphs.jlAbstractGraphinterface for theIGraphtype, enablingIGraphto be used with all existing Graphs.jl algorithms that operate through the API.Changes
New interface methods:
Graphs.edges— lazyIGraphEdgeIteratorover igraph edge IDs (0→1 index conversion)Graphs.outneighbors/Graphs.inneighbors— viaLibIGraph.neighborswith sorted outputGraphs.add_edge!(g, s, d)— with duplicate-edge and self-loop guardsGraphs.add_vertex!— via rawigraph_add_verticesccallGraphs.rem_vertex!— viaigraph_delete_verticeswithigraph_vss_1selectorBase.copy— viaLibIGraph.copyinto uninitializedIGraphBug fix:
Graphs.has_edgenow correctly converts 1-based Julia indices to 0-based igraph indices before callingget_eidTests:
GraphsInterfaceChecker.jlas a test dependencyAbstractGraphinterfaceMotivation
This addresses part of #446: "Complete Graph API support for the IGraph types (so that IGraph types can be used in all already existing Graph.jl algorithms that do not peek behind the API)" and "use GraphsInterfaceChecker.jl in the test suite".