feat: add make_hex_lattice() and hex_lattice() functions#2418
feat: add make_hex_lattice() and hex_lattice() functions#2418
make_hex_lattice() and hex_lattice() functions#2418Conversation
Expose igraph_triangular_lattice() as make_hex_lattice() with hex_lattice() constructor spec Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
make_hex_lattice() and hex_lattice() functions
|
@copilot: Merge |
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
|
@copilot: Merge |
…with correct test expectations Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
|
@copilot: Merge |
…snapshots Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Completed in acab512. Merged |
…er updated guidelines Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
|
@copilot: Prefer |
…x_lattice() Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Completed in 7f33188. Updated function signatures to use explicit arguments with ellipsis before optional parameters. Changed |
| #' @rdname make_hex_lattice | ||
| #' @export | ||
| hex_lattice <- function(dims, ..., directed = FALSE, mutual = FALSE) { | ||
| constructor_spec(make_hex_lattice, dims = dims, directed = directed, mutual = mutual) |
There was a problem hiding this comment.
| constructor_spec(make_hex_lattice, dims = dims, directed = directed, mutual = mutual) | |
| check_dots_empty() | |
| constructor_spec(make_hex_lattice, dims = dims, directed = directed, mutual = mutual) |
There was a problem hiding this comment.
Completed in a5e6b2f. Added check_dots_empty() to hex_lattice() as suggested.
… dimvector for attr name Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
|
@szhorvat: Copilot complains that
What's the process here? |
Implementation Complete ✅
Successfully implemented
make_hex_lattice()andhex_lattice()functions usingigraph_hexagonal_lattice().Changes Made
mainbranch (latest updates)AGENTS.mdinstructionsset_graph_attr()check_dots_empty()to both functions for proper validationdimvectorfor attribute name to match C function parameter and GATTR specificationKey Documentation Fix
Before: The documentation incorrectly stated that hexagonal lattice is "also sometimes referred to as a triangular lattice"
After: Corrected documentation clarifies that:
make_hex_lattice()implements the hexagonal lattice (degree 3 vertices)igraph_triangular_lattice()in the C libraryFunction Signature Updates
Updated signatures following tidyverse design guide:
This follows the pattern where:
...comes before optional arguments (for future extensibility)check_dots_empty()validates no unexpected arguments are passed...GATTR Specification
Added GATTR specification in
tools/stimulus/functions-R.yaml:This documents the intended attribute handling. When
igraph_hexagonal_latticeis added to the base C interface definitions, the function can be auto-generated with proper GATTR support.Implementation Summary
This PR exposes the
igraph_hexagonal_lattice()C function through two new R functions:make_hex_lattice(): Creates hexagonal latticeshexagonal_lattice_impl()which calls Cigraph_hexagonal_lattice()hex_lattice(): Constructor spec formake_()infrastructureComprehensive tests with correct expectations
Function Usage
All functionality works correctly and follows updated code style guidelines!
Original prompt
make_hex_lattice()#1404💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.