Skip to content

Add VNAlgorithm dispatch for very_nauty C library algorithms#19

Open
nenadilic84 wants to merge 2 commits intoJuliaGraphs:masterfrom
nenadilic84:feat/vnalgorithm-dispatch
Open

Add VNAlgorithm dispatch for very_nauty C library algorithms#19
nenadilic84 wants to merge 2 commits intoJuliaGraphs:masterfrom
nenadilic84:feat/vnalgorithm-dispatch

Conversation

@nenadilic84
Copy link
Copy Markdown

Summary

Adds a VNAlgorithm dispatch type that routes graph algorithms to the very_nauty C library implementation, following the pattern specified in JuliaGraphs/Graphs.jl#448.

New API

using VNGraphs
import Graphs

g = Graphs.cycle_graph(5)

# Dispatch to very_nauty via VNAlgorithm()
Graphs.is_connected(g, VNAlgorithm())        # true
Graphs.connected_components(g, VNAlgorithm()) # [[1, 2, 3, 4, 5]]

# very_nauty-specific algorithms (not in Graphs.jl)
chromatic_number(g, VNAlgorithm())       # 3  (exact, via exhaustive search)
edge_chromatic_number(g, VNAlgorithm())  # 3
clique_number(g, VNAlgorithm())          # 2

Design

  • VNAlgorithm is an exported dispatch type
  • All methods accept any AbstractGraph and auto-convert to VNGraph internally when needed
  • is_connected and connected_components extend existing Graphs.jl functions
  • chromatic_number, edge_chromatic_number, and clique_number are new functions exported from VNGraphs (these algorithms don't exist in Graphs.jl yet)

Algorithms dispatched

Function C library call Notes
Graphs.is_connected(g, ::VNAlgorithm) graph_connected Returns Bool
Graphs.connected_components(g, ::VNAlgorithm) graph_nclusters + cluster labels Returns Vector{Vector{Int}}
chromatic_number(g, ::VNAlgorithm; timeout=0) graph_chromatic_number Exact, optional timeout
edge_chromatic_number(g, ::VNAlgorithm; timeout=0) graph_edge_chromatic_number Exact, optional timeout
clique_number(g, ::VNAlgorithm) graph_clique_number Exact

Bounty checklist progress (Graphs.jl#448)

  • Dispatch from operations to very_nauty implementation via VNAlgorithm
  • Declare missing algorithms in Graphs.jl (chromatic_number, clique_number — separate PR to Graphs.jl)

All 307 tests pass locally on Julia 1.11.

- Implement edges iterator (VNGraphEdgeIterator) for memory-efficient
  edge traversal without collecting to array
- Implement outneighbors/inneighbors returning sorted 1-based indices
- Fix has_edge to convert 1-based Julia indices to 0-based C indices
- Add rem_edge! using graph_del_edge from C library
- Add add_vertex! using graph_add_node from C library
- Add copy for independent graph duplication
- Fix vertices return type annotation
- Add GraphsInterfaceChecker.jl compliance tests
- Add comprehensive tests for edges, neighbors, mutation, copy,
  and round-trip consistency with various graph types
- Add VNAlgorithm dispatch type for routing algorithms to very_nauty
- Dispatch is_connected(g, VNAlgorithm()) via graph_connected
- Dispatch connected_components(g, VNAlgorithm()) via graph_nclusters
  with cluster label extraction
- Add chromatic_number(g, VNAlgorithm()) for exact chromatic number
- Add edge_chromatic_number(g, VNAlgorithm()) for exact edge chromatic number
- Add clique_number(g, VNAlgorithm()) for exact clique number
- Auto-conversion: all methods accept any AbstractGraph, converting
  to VNGraph internally when needed
- Comprehensive tests for all algorithms with known graph properties
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.52%. Comparing base (b1faf64) to head (8e2947f).

Additional details and impacted files
@@             Coverage Diff             @@
##           master      #19       +/-   ##
===========================================
+ Coverage   45.90%   86.52%   +40.62%     
===========================================
  Files           1        1               
  Lines          61      141       +80     
===========================================
+ Hits           28      122       +94     
+ Misses         33       19       -14     

☔ 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

All CI test jobs pass across all platforms (ubuntu, windows, macOS x64, macOS aarch64).

The only failing check is Documentation — same pre-existing issue as PR #18 (no docs/make.jl in the repo).

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