Skip to content

feat: Add attribute combination support to graph operators#2676

Open
schochastics wants to merge 5 commits into
mainfrom
feat-attrib_comb
Open

feat: Add attribute combination support to graph operators#2676
schochastics wants to merge 5 commits into
mainfrom
feat-attrib_comb

Conversation

@schochastics
Copy link
Copy Markdown
Contributor

fix #57

@schochastics
Copy link
Copy Markdown
Contributor Author

devtools::document() doesnt work locally for me

Comment on lines +1317 to +1325
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)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to helper or a proper R/ function?

Comment thread R/attributes.R
#############

igraph.i.attribute.combination <- function(comb) {
igraph.i.attribute.combination <- function(comb, allow_rename = FALSE) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split into two functions, one for a scalar, and the list function as a simple wrapper?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not.

Comment thread R/operators.R
default_comb <- if (length(default_idx) > 0) {
comb[[default_idx[1]]]
} else {
"rename"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"rename"
# Backward-compatible standard
"rename"

Comment thread R/operators.R
#' print_all(g1 %du% g2)
#' @export
disjoint_union <- function(...) {
disjoint_union <- function(..., graph.attr.comb = "rename") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread R/operators.R
###################################################################

rename.attr.if.needed <- function(
combine.attrs <- function(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep rename_attr_if_needed() and use it only for those attributes where the action is "rename"?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

This is how benchmark results would change (along with a 95% confidence interval in relative change) if cb49b91 is merged into main:

  • ✔️as_adjacency_matrix: 724ms -> 723ms [-0.49%, +0.12%]
  • ✔️as_biadjacency_matrix: 723ms -> 725ms [-0.23%, +0.56%]
  • ✔️as_data_frame_both: 1.5ms -> 1.49ms [-1.4%, +0.34%]
  • ✔️as_long_data_frame: 3.88ms -> 3.89ms [-0.57%, +0.88%]
  • ❗🐌es_attr_filter: 2.7ms -> 2.74ms [+0.21%, +2.49%]
  • ✔️graph_from_adjacency_matrix: 130ms -> 129ms [-1.25%, +0.45%]
  • ✔️graph_from_data_frame: 3.4ms -> 3.42ms [-0.21%, +1.04%]
  • ✔️vs_attr_filter: 1.54ms -> 1.53ms [-1.32%, +0.33%]
  • ✔️vs_by_name: 1000µs -> 990µs [-2.01%, +0.09%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

R: API for combining attributes from different graphs

2 participants