feat: Add attribute combination support to graph operators#2676
feat: Add attribute combination support to graph operators#2676schochastics wants to merge 9 commits into
Conversation
…tion, compose, disjoint_union)
|
devtools::document() doesnt work locally for me |
| make_named_pair <- function() { | ||
| g1 <- graph_from_literal(A - B, B - C, C - A) | ||
| g2 <- graph_from_literal(A - B, B - C, C - A) | ||
| V(g1)$weight <- c(1, 2, 3) | ||
| V(g2)$weight <- c(10, 20, 30) | ||
| E(g1)$weight <- c(1, 2, 3) | ||
| E(g2)$weight <- c(10, 20, 30) | ||
| list(g1 = g1, g2 = g2) | ||
| } |
There was a problem hiding this comment.
Move to helper or a proper R/ function?
| ############# | ||
|
|
||
| igraph.i.attribute.combination <- function(comb) { | ||
| igraph.i.attribute.combination <- function(comb, allow_rename = FALSE) { |
There was a problem hiding this comment.
Split into two functions, one for a scalar, and the list function as a simple wrapper?
| default_comb <- if (length(default_idx) > 0) { | ||
| comb[[default_idx[1]]] | ||
| } else { | ||
| "rename" |
There was a problem hiding this comment.
| "rename" | |
| # Backward-compatible standard | |
| "rename" |
| #' print_all(g1 %du% g2) | ||
| #' @export | ||
| disjoint_union <- function(...) { | ||
| disjoint_union <- function(..., graph.attr.comb = "rename") { |
There was a problem hiding this comment.
| disjoint_union <- function(..., graph.attr.comb = "rename") { | |
| disjoint_union <- function(..., graph_attr_comb = "rename") { |
and clean up edge.attr.comb ? Think harder about naming, but the names already are long enough.
| ################################################################### | ||
|
|
||
| rename.attr.if.needed <- function( | ||
| combine.attrs <- function( |
There was a problem hiding this comment.
Keep rename_attr_if_needed() and use it only for those attributes where the action is "rename"?
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c26ab02 is merged into main:
|
…lper Address review feedback on #2676: - Rename the new graph.attr.comb/vertex.attr.comb/edge.attr.comb arguments of union()/intersection()/compose()/disjoint_union() to snake_case (these args are new in this PR, so no deprecation is needed). - Extract rename_attr_if_needed() back out of combine.attrs() for the "rename" strategy, preserving the historical overwrite-on-clash semantics under chains of %du%. - Add a clarifying comment on the backward-compatible "rename" default. - Move the make_named_pair() test helper into helper.R. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tted names Follow-up to review feedback on #2676 ("clean up edge.attr.comb"): - simplify(), as_undirected() and contract() gain snake_case edge_attr_comb / vertex_attr_comb arguments via the argument-migration infrastructure (tools/migrations.R). The old dotted names still work and emit a single lifecycle::deprecate_soft() warning. - Rename the matching igraph option keys edge.attr.comb -> edge_attr_comb and vertex.attr.comb -> vertex_attr_comb, with back-compatible aliasing in igraph_opt()/igraph_options(); the dotted keys still read and set, soft- deprecated. Update the stimulus codegen default (types-RR.yaml) and the regenerated *_impl defaults to match. Deprecated wrappers (as.undirected(), contract.vertices()) are left frozen; their snapshot now records the resulting layered deprecation warnings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if b58da44 is merged into main:
|
| "vertex_attr_comb" = list(name = "concat", "ignore"), | ||
| "edge_attr_comb" = list(weight = "sum", name = "concat", "ignore"), |
fix #57