Skip to content

Commit f335f4e

Browse files
krlmlraviator-bot
authored and
aviator-bot
committed
feat: Stop accepting setting layout as a graph attribute if it is a matrix
1 parent 79239ef commit f335f4e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

R/attributes.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,21 @@ graph_attr <- function(graph, name) {
336336
set_graph_attr <- function(graph, name, value) {
337337
ensure_igraph(graph)
338338

339+
# Code that accesses g$layout can stay for now, revisit in 2029.
340+
if (name == "layout" && is.matrix(value)) {
341+
if (ncol(value) == 2) {
342+
lifecycle::deprecate_stop("2.0.3", "set_graph_attr(layout = 'matrix(...)')", details = "Using a matrix for the `layout` attribute is deprecated. Use vertex attributes `x` and `y` instead.")
343+
value <- list(x = value[, 1], y = value[, 2])
344+
} else if (ncol(value) == 3) {
345+
lifecycle::deprecate_stop("2.0.3", "set_graph_attr(layout = 'matrix(...)')", details = "Using a matrix for the `layout` attribute is deprecated. Use vertex attributes `x`, `y` and `z` instead.")
346+
value <- list(x = value[, 1], y = value[, 2], z = value[, 3])
347+
} else {
348+
lifecycle::deprecate_stop("2.0.3", "set_graph_attr(layout = 'matrix(...)')", details = "Using a matrix for the `layout` attribute is defunct. Use vertex attributes `x`, `y` and `z` instead.")
349+
}
350+
351+
return(set_vertex_attr(graph, name, value))
352+
}
353+
339354
.Call(R_igraph_mybracket3_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, name, value)
340355
}
341356

0 commit comments

Comments
 (0)