Skip to content

Complete Graphs.jl AbstractGraph API for IGraph#35

Open
nenadilic84 wants to merge 2 commits intoJuliaGraphs:masterfrom
nenadilic84:feat/complete-graphs-api
Open

Complete Graphs.jl AbstractGraph API for IGraph#35
nenadilic84 wants to merge 2 commits intoJuliaGraphs:masterfrom
nenadilic84:feat/complete-graphs-api

Conversation

@nenadilic84
Copy link
Copy Markdown

Summary

This PR completes the Graphs.jl AbstractGraph interface for the IGraph type, enabling IGraph to be used with all existing Graphs.jl algorithms that operate through the API.

Changes

New interface methods:

  • Graphs.edges — lazy IGraphEdgeIterator over igraph edge IDs (0→1 index conversion)
  • Graphs.outneighbors / Graphs.inneighbors — via LibIGraph.neighbors with sorted output
  • Graphs.add_edge!(g, s, d) — with duplicate-edge and self-loop guards
  • Graphs.add_vertex! — via raw igraph_add_vertices ccall
  • Graphs.rem_vertex! — via igraph_delete_vertices with igraph_vss_1 selector
  • Base.copy — via LibIGraph.copy into uninitialized IGraph

Bug fix:

  • Graphs.has_edge now correctly converts 1-based Julia indices to 0-based igraph indices before calling get_eid

Tests:

  • Added GraphsInterfaceChecker.jl as a test dependency
  • New test file validates both mandatory and optional (mutation) parts of the AbstractGraph interface
  • Additional explicit tests for edges roundtrip, neighbors, has_edge, and mutation operations
  • All 305 tests pass (up from 267)

Motivation

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".

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
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 6.37%. Comparing base (d37f19c) to head (ebd6464).

Files with missing lines Patch % Lines
src/graph_api.jl 97.14% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nenadilic84
Copy link
Copy Markdown
Author

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:

  • Documentation: docs/make.jl does not exist in the repo yet
  • Spell Check: .typos.toml config file is missing from the repo
  • evaluate: SnoopCompile FieldError on Core.Binding (tooling compatibility issue)
  • performance-tracking: BenchmarkCI JSON parse error
  • JET: "Bad include call" from include(modifymodule, "LibIGraph.jl") pattern
  • Julia alpha: JET incompatible with Julia 1.13 beta

All actual test jobs pass on all platforms (ubuntu, macOS x64/aarch64, windows) and on Julia 1.10.

@nenadilic84
Copy link
Copy Markdown
Author

/claim #446

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