Skip to content

Commit

Permalink
Merge branch 'main' into again-cut.prob
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle authored Mar 6, 2025
2 parents 5fd1137 + 7b36cde commit db23e4a
Show file tree
Hide file tree
Showing 334 changed files with 7,838 additions and 6,869 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ pak::pak("igraph/igraph.r2cdocs")
[roxygen2](https://roxygen2.r-lib.org/), and run `devtools::document()` or `make
igraph` to update the `.Rd` files.

- Links to C docs are added using the cdocs tag, for instance:

```
#' @cdocs igraph_assortativity
```

### Maintaining igraph.r2cdocs

To update the data (when the C docs index has changed after a release) in https://github.com/igraph/igraph.r2cdocs/, run the script that is `data-raw`, commit the csv file and push.

### Test Cases

Unless you change something trivial, please consider adding test cases. This is
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: igraph
Title: Network Analysis and Visualization
Version: 2.1.4.9011
Version: 2.1.4.9019
Authors@R: c(
person("Gábor", "Csárdi", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0001-7098-9676")),
Expand Down Expand Up @@ -65,7 +65,7 @@ VignetteBuilder:
knitr
Config/Needs/build: roxygen2, devtools, irlba, pkgconfig, igraph/igraph.r2cdocs, moodymudskipper/devtag
Config/Needs/coverage: covr
Config/Needs/website: readr
Config/Needs/website: here, readr, tibble, xmlparsedata, xml2
Config/testthat/edition: 3
Config/testthat/parallel: true
Config/testthat/start-first: vs-es, scan, vs-operators, weakref,
Expand Down
114 changes: 114 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,119 @@
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->

# igraph 2.1.4.9019

## Testing

- Added tests for untested files (@schochastics, #1728).

- Merged and refactored other.R tests (@schochastics, #1727).

- Merged and refactored structural.properties.R tests (@schochastics, #1726).


# igraph 2.1.4.9018

## Bug fixes

- Use function instead of (x) in arrow.mode (@schochastics, #1722).

## Documentation

- Lifecycle table (#1525).

## Refactoring

- One less tmp use case (#1715).

## Testing

- Merged and refactored orphaned test files (@schochastics, #1724).

- Merged and refactored iterators.R and operators.R tests (@schochastics, #1723).

- Merged and refactored topology.R tests (@schochastics, #1720).

- Merged and refactored embedding.R tests (@schochastics, #1721).

- Merge all tests for foreign.R into one test file (#1713).


# igraph 2.1.4.9017

## Features

- Added proper support for adding attributes via data.frames (@schochastics, #1373, #1669, #1716).


# igraph 2.1.4.9016

## doc

- Fix typos in `laplacian_matrix` documentation.


# igraph 2.1.4.9015

## Chore

- Run `devtools::document()` (#1710).


# igraph 2.1.4.9014

## Bug fixes

- Duplicated arrowhead drawing (@schochastics, #640, #1709).

- Correct mapping of edge label properties in plots when loops are present (@schochastics, #157, #1706).

- NA attribute values are replaced with default values for plotting (@schochastics, #293, #1707).

## vendor

- Update vendored sources to igraph/igraph@10ef19bc2a61de6c6cfe76e5a068f82b1d29fff1 (#1694).


# igraph 2.1.4.9013

## Features

- Hrg functions check their argument (#1074, #1699).

## Documentation

- Replace instances of `#' if` with `#' @examplesIf` (#1134, #1698).

- Update graph saving rec (#1242, #1700).

## Testing

- Improve test-dot.product.game (#1396, #1705).


# igraph 2.1.4.9012

## Chore

- Run {styler} (with {igraph.style}) (#1696).

## Documentation

- Add more about igraph.r2cdocs in the contributing guide (#1686, #1697).

## Testing

- Merged and refactored conversion.R tests (@schochastics, #1701).

- Create helpers (#1691, #1695).

- Merged and refactored make.R tests (@schochastics, #1685).

- Merged and refactored community.R tests (@schochastics, #1689).

- Merged and refactored indexing.R tests (@schochastics, #1687).


# igraph 2.1.4.9011

## Testing
Expand Down
15 changes: 13 additions & 2 deletions R/aaa-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -2712,14 +2712,25 @@ triad_census_impl <- function(graph) {
res
}

adjacent_triangles_impl <- function(graph, vids=V(graph)) {
count_adjacent_triangles_impl <- function(graph, vids=V(graph)) {
# Argument checks
ensure_igraph(graph)
vids <- as_igraph_vs(graph, vids)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_adjacent_triangles, graph, vids-1)
res <- .Call(R_igraph_count_adjacent_triangles, graph, vids-1)

res
}

count_triangles_impl <- function(graph) {
# Argument checks
ensure_igraph(graph)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_count_triangles, graph)

res
}
Expand Down
4 changes: 2 additions & 2 deletions R/adjacency.R
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ mysummary <- function(x) {
result
}

pmax_AB <- function(A,B) {
change <- A < B
pmax_AB <- function(A, B) {
change <- A < B
A[change] <- B[change]
A
}
Expand Down
1 change: 0 additions & 1 deletion R/assortativity.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Assortativity coefficient
#'
#' @description
Expand Down
56 changes: 26 additions & 30 deletions R/attributes.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Set vertex attributes
#'
#' @description
Expand Down Expand Up @@ -350,6 +349,9 @@ graph.attributes <- function(graph) {
"graph.attributes<-" <- function(graph, value) {
ensure_igraph(graph)
assert_named_list(value)
if (inherits(value, "data.frame")) {
value <- as.list(value)
}

.Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, value)
}
Expand Down Expand Up @@ -391,7 +393,6 @@ vertex_attr <- function(graph, name, index = V(graph)) {
}
index <- as_igraph_vs(graph, index)
myattr[index]

}

#' Set one or more vertex attributes
Expand Down Expand Up @@ -489,12 +490,8 @@ i_set_vertex_attr <- function(graph, name, index = V(graph), value, check = TRUE
} else if (length(value) == length(index)) {
value_in <- unname(value)
} else {
stop(
"Length of new attribute value must be ",
if (length(index) != 1) "1 or ",
length(index),
", the number of target vertices, not ",
length(value)
cli::cli_abort(
"Length of new attribute value must be {if (length(index) != 1) '1 or '}{length(index)}, the number of target vertices, not {length(value)}."
)
}

Expand All @@ -520,8 +517,8 @@ vertex.attributes <- function(graph, index = V(graph)) {

if (!missing(index)) {
index_is_natural_sequence <- (length(index) == vcount(graph) &&
identical(index, seq(1, vcount(graph))))
if (!index_is_natural_sequence) {
identical(index, seq(1, vcount(graph))))
if (!index_is_natural_sequence) {
for (i in seq_along(res)) {
res[[i]] <- res[[i]][index]
}
Expand All @@ -543,16 +540,19 @@ set_value_at <- function(value, idx, length_out) {
ensure_igraph(graph)

assert_named_list(value)
if (inherits(value, "data.frame")) {
value <- as.list(value)
}

if (!all(lengths(value) == length(index))) {
stop("Invalid attribute value length, must match number of vertices")
cli::cli_abort("Invalid attribute value length, must match number of vertices.")
}

if (!missing(index)) {
index <- as_igraph_vs(graph, index)

if (anyDuplicated(index) || anyNA(index)) {
stop("Invalid vertices in index")
cli::cli_abort("{.arg index} contains duplicated vertices or NAs.")
}
}

Expand Down Expand Up @@ -700,12 +700,8 @@ i_set_edge_attr <- function(graph, name, index = E(graph), value, check = TRUE)
} else if (length(value) == length(index)) {
value_in <- unname(value)
} else {
stop(
"Length of new attribute value must be ",
if (length(index) != 1) "1 or ",
length(index),
", the number of target edges, not ",
length(value)
cli::cli_abort(
"Length of new attribute value must be {if (length(index) != 1) '1 or '}{length(index)}, the number of target edges, not {length(value)}."
)
}

Expand Down Expand Up @@ -743,15 +739,18 @@ edge.attributes <- function(graph, index = E(graph)) {
ensure_igraph(graph)

assert_named_list(value)
if (inherits(value, "data.frame")) {
value <- as.list(value)
}

if (any(sapply(value, length) != length(index))) {
stop("Invalid attribute value length, must match number of edges")
cli::cli_abort("Invalid attribute value length, must match number of edges")
}

if (!missing(index)) {
index <- as_igraph_es(graph, index)
if (any(duplicated(index)) || any(is.na(index))) {
stop("Invalid edges in index")
cli::cli_abort("{.arg index} contains duplicated edges or NAs.")
}
}

Expand Down Expand Up @@ -857,7 +856,7 @@ delete_graph_attr <- function(graph, name) {

name <- as.character(name)
if (!name %in% graph_attr_names(graph)) {
stop("No such graph attribute: ", name)
cli::cli_abort("No graph attribute {.arg {name}} found.")
}

gattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)
Expand Down Expand Up @@ -886,7 +885,7 @@ delete_vertex_attr <- function(graph, name) {

name <- as.character(name)
if (!name %in% vertex_attr_names(graph)) {
stop("No such vertex attribute: ", name)
cli::cli_abort("No vertex attribute {.arg {name}} found.")
}

vattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex)
Expand Down Expand Up @@ -915,7 +914,7 @@ delete_edge_attr <- function(graph, name) {

name <- as.character(name)
if (!name %in% edge_attr_names(graph)) {
stop("No such edge attribute: ", name)
cli::cli_abort("No edge attribute {.arg {name}} found.")
}

eattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge)
Expand Down Expand Up @@ -1022,7 +1021,7 @@ igraph.i.attribute.combination <- function(comb) {
if (any(!sapply(comb, function(x) {
is.function(x) || (is.character(x) && length(x) == 1)
}))) {
stop("Attribute combination element must be a function or character scalar")
cli::cli_abort("Attribute combination element must be a function or character scalar.")
}
if (is.null(names(comb))) {
names(comb) <- rep("", length(comb))
Expand All @@ -1043,7 +1042,7 @@ igraph.i.attribute.combination <- function(comb) {
)
x <- pmatch(tolower(x), known[, 1])
if (is.na(x)) {
stop("Unknown/unambigous attribute combination specification")
cli::cli_abort("Unknown/unambigous attribute combination specification.")
}
known[, 2][x]
}
Expand Down Expand Up @@ -1187,18 +1186,15 @@ NULL
}

assert_named_list <- function(value) {
error_msg <- "{.arg value} must be a named list with unique names"

if (!is.list(value)) {
rlang::abort(error_msg)
cli::cli_abort("{.arg value} must be a named list with unique names")
}

if (length(value) == 0) {
return()
}

if (!rlang::is_named(value) || anyDuplicated(names(value)) > 0) {

rlang::abort(error_msg)
cli::cli_abort("{.arg value} must be a named list with unique names")
}
}
1 change: 0 additions & 1 deletion R/basic.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Is this object an igraph graph?
#'
#' @description
Expand Down
1 change: 0 additions & 1 deletion R/bipartite.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Project a bipartite graph
#'
#' @description
Expand Down
Loading

0 comments on commit db23e4a

Please sign in to comment.