@@ -516,9 +516,7 @@ vertex.attributes <- function(graph, index = V(graph)) {
516
516
res <- .Call(R_igraph_mybracket2_copy , graph , igraph_t_idx_attr , igraph_attr_idx_vertex )
517
517
518
518
if (! missing(index )) {
519
- index_is_natural_sequence <- (length(index ) == vcount(graph ) &&
520
- identical(index , seq(1 , vcount(graph ))))
521
- if (! index_is_natural_sequence ) {
519
+ if (! index_is_natural_sequence(index , graph )) {
522
520
for (i in seq_along(res )) {
523
521
res [[i ]] <- res [[i ]][index ]
524
522
}
@@ -556,8 +554,7 @@ set_value_at <- function(value, idx, length_out) {
556
554
}
557
555
}
558
556
559
- index_is_natural_sequence <- (length(index ) == vcount(graph ) && all(index == V(graph )))
560
- if (! missing(index ) && ! index_is_natural_sequence ) {
557
+ if (! missing(index ) && ! index_is_natural_sequence(index , graph )) {
561
558
value <- map(value , set_value_at , idx = index , length_out = length(V(graph )))
562
559
}
563
560
@@ -1198,3 +1195,7 @@ assert_named_list <- function(value) {
1198
1195
cli :: cli_abort(" {.arg value} must be a named list with unique names" )
1199
1196
}
1200
1197
}
1198
+
1199
+ index_is_natural_sequence <- function (index , graph ) {
1200
+ length(index ) == vcount(graph ) && all(index == seq_len(vcount(graph )))
1201
+ }
0 commit comments