Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove deprecated functions before 1.0 #1352

Merged
merged 46 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ef561c4
revert me: add warnings
Antonov548 May 2, 2024
453d712
`igraph_authority_score` and `igraph_hub_score`
Antonov548 May 2, 2024
af12df9
rename to `hits_scores`
Antonov548 May 3, 2024
18acec2
add compatible methods
Antonov548 May 7, 2024
af690ef
export
Antonov548 May 7, 2024
df048c6
Automated changes
Antonov548 May 7, 2024
e5439f8
`square_lattice` replace deprecated `R_igraph_lattice`
Antonov548 May 8, 2024
49630cf
remove `R_igraph_lattice`
Antonov548 May 8, 2024
ac20b26
update `make_lattice` tests
Antonov548 May 8, 2024
10ed7d0
use deperacted strategy for `make_lattice`
Antonov548 May 8, 2024
15650c3
update `periodic` description
Antonov548 May 13, 2024
5759869
update `laplacian_matrix`
Antonov548 May 13, 2024
4cc8053
add compatibility logic for `laplacian_matrix`
Antonov548 May 13, 2024
2ec6d54
remove `igraph_bipartite_game`
Antonov548 May 15, 2024
2af2c16
update `functions-R.yaml`
Antonov548 May 15, 2024
8f42c47
regenerate cpp11
Antonov548 May 15, 2024
1530976
remove `R_igraph_erdos_renyi_game`
Antonov548 May 15, 2024
6093da8
remove `R_igraph_random_edge_walk`
Antonov548 May 16, 2024
808f2ca
dissable warnings
Antonov548 May 16, 2024
ebd4066
Update R/centrality.R
Antonov548 May 29, 2024
8436b4d
Update R/centrality.R
Antonov548 May 29, 2024
5e8f90c
fix typo
Antonov548 May 29, 2024
532b26a
add comments
Antonov548 May 29, 2024
5dfcb5a
restore functions
Antonov548 May 30, 2024
158c26c
Automated changes
Antonov548 May 30, 2024
8f2f57d
feat!: make deprecation warn, refer to hits_score()
maelle May 30, 2024
94051e7
refactor: indentation
maelle May 30, 2024
2b4a55a
refactor: use rlang::check_dots_empty()
maelle May 30, 2024
08b99d0
refactor: make output more similar to old output
maelle May 30, 2024
e484d5b
docs: fix docs for r cmd check
maelle May 30, 2024
1db8ede
docs: fix docs
maelle May 30, 2024
57b955f
docs: fix for pkgdown, re-add keyword
maelle May 30, 2024
4d3d486
docs: fix copy-paste mistake
maelle May 30, 2024
0fc4a01
Results
krlmlr Jun 4, 2024
43b30bc
Merge branch 'main' into fix/deprecated
krlmlr Jun 6, 2024
e389077
docs: update example for hits_scores()
maelle Jun 6, 2024
4da1aac
rename params
Antonov548 Jun 7, 2024
b10939c
Merge branch 'main' into fix/deprecated
Antonov548 Jun 10, 2024
26e8ecc
update cpp11
Antonov548 Jun 10, 2024
bc3e903
chore: Bump
krlmlr Jun 11, 2024
900b490
remove R_igraph_lattice
Antonov548 Jun 12, 2024
d61dc0a
update docs
Antonov548 Jun 12, 2024
ec1aa2c
Merge remote-tracking branch 'origin/main' into fix/deprecated
Antonov548 Jun 13, 2024
c2f4d1b
update interface
Antonov548 Jun 13, 2024
c338cd9
Merge branch 'main' into fix/deprecated
krlmlr Jun 16, 2024
b974789
Results
krlmlr Jun 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ export(head_of)
export(head_print)
export(hierarchical_sbm)
export(hierarchy)
export(hits_scores)
export(hrg)
export(hrg.consensus)
export(hrg.create)
Expand Down
124 changes: 30 additions & 94 deletions R/aaa-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,34 @@ turan_impl <- function(n, r) {
res
}

erdos_renyi_game_gnp_impl <- function(n, p, directed=FALSE, loops=FALSE) {
# Argument checks
n <- as.numeric(n)
p <- as.numeric(p)
directed <- as.logical(directed)
loops <- as.logical(loops)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_erdos_renyi_game_gnp, n, p, directed, loops)

res
}

erdos_renyi_game_gnm_impl <- function(n, m, directed=FALSE, loops=FALSE) {
# Argument checks
n <- as.numeric(n)
m <- as.numeric(m)
directed <- as.logical(directed)
loops <- as.logical(loops)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_erdos_renyi_game_gnm, n, m, directed, loops)

res
}

forest_fire_game_impl <- function(nodes, fw.prob, bw.factor=1, ambs=1, directed=TRUE) {
# Argument checks
nodes <- as.numeric(nodes)
Expand Down Expand Up @@ -1411,52 +1439,6 @@ eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weigh
res
}

hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
# Argument checks
ensure_igraph(graph)
scale <- as.logical(scale)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
if (!is.null(weights) && any(!is.na(weights))) {
weights <- as.numeric(weights)
} else {
weights <- NULL
}
options <- modify_list(arpack_defaults(), options)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_hub_score, graph, scale, weights, options)
if (igraph_opt("add.vertex.names") && is_named(graph)) {
names(res$vector) <- vertex_attr(graph, "name", V(graph))
}
res
}

authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
# Argument checks
ensure_igraph(graph)
scale <- as.logical(scale)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
if (!is.null(weights) && any(!is.na(weights))) {
weights <- as.numeric(weights)
} else {
weights <- NULL
}
options <- modify_list(arpack_defaults(), options)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_authority_score, graph, scale, weights, options)
if (igraph_opt("add.vertex.names") && is_named(graph)) {
names(res$vector) <- vertex_attr(graph, "name", V(graph))
}
res
}

hub_and_authority_scores_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
# Argument checks
ensure_igraph(graph)
Expand All @@ -1475,10 +1457,10 @@ hub_and_authority_scores_impl <- function(graph, scale=TRUE, weights=NULL, optio
# Function call
res <- .Call(R_igraph_hub_and_authority_scores, graph, scale, weights, options)
if (igraph_opt("add.vertex.names") && is_named(graph)) {
names(res$hub.vector) <- vertex_attr(graph, "name", V(graph))
names(res$hub) <- vertex_attr(graph, "name", V(graph))
}
if (igraph_opt("add.vertex.names") && is_named(graph)) {
names(res$authority.vector) <- vertex_attr(graph, "name", V(graph))
names(res$authority) <- vertex_attr(graph, "name", V(graph))
}
res
}
Expand Down Expand Up @@ -1986,34 +1968,6 @@ random_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "i
res
}

random_edge_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) {
# Argument checks
ensure_igraph(graph)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
if (!is.null(weights) && any(!is.na(weights))) {
weights <- as.numeric(weights)
} else {
weights <- NULL
}
start <- as_igraph_vs(graph, start)
if (length(start) == 0) {
stop("No vertex was specified")
}
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)
steps <- as.numeric(steps)
stuck <- switch(igraph.match.arg(stuck), "error" = 0L, "return" = 1L)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_random_edge_walk, graph, weights, start-1, mode, steps, stuck)
if (igraph_opt("return.vs.es")) {
res <- create_es(graph, res)
}
res
}

global_efficiency_impl <- function(graph, weights=NULL, directed=TRUE) {
# Argument checks
ensure_igraph(graph)
Expand Down Expand Up @@ -2197,24 +2151,6 @@ is_bipartite_impl <- function(graph) {
res
}

bipartite_game_impl <- function(type, n1, n2, p=0.0, m=0, directed=FALSE, mode=c("all", "out", "in", "total")) {
# Argument checks
n1 <- as.numeric(n1)
n2 <- as.numeric(n2)
p <- as.numeric(p)
m <- as.numeric(m)
directed <- as.logical(directed)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_bipartite_game, type, n1, n2, p, m, directed, mode)
if (igraph_opt("add.vertex.names") && is_named(graph)) {
names(res$types) <- vertex_attr(graph, "name", V(graph))
}
res
}

get_laplacian_impl <- function(graph, mode=c("out", "in", "all", "total"), normalization=c("unnormalized", "symmetric", "left", "right"), weights=NULL) {
# Argument checks
ensure_igraph(graph)
Expand Down
100 changes: 67 additions & 33 deletions R/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,25 @@ page.rank <- function(graph, algo = c("prpack", "arpack"), vids = V(graph), dire
#' @keywords internal
#' @export
hub.score <- function(graph, scale = TRUE, weights = NULL, options = arpack_defaults()) { # nocov start
lifecycle::deprecate_soft("2.0.0", "hub.score()", "hub_score()")
maelle marked this conversation as resolved.
Show resolved Hide resolved
lifecycle::deprecate_warn("2.0.0", "hub.score()", "hits_score()")
hub_score(graph = graph, scale = scale, weights = weights, options = options)
} # nocov end

#' Kleinberg's hub and authority centrality scores.
#'
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' `authority.score()` was renamed to `authority_score()` to create a more
#' consistent API.
#' @inheritParams authority_score
#' @keywords internal
#' @export
authority.score <- function(graph, scale = TRUE, weights = NULL, options = arpack_defaults()) { # nocov start
lifecycle::deprecate_warn("2.0.0", "authority.score()", "hits_score()")
authority_score(graph = graph, scale = scale, weights = weights, options = options)
} # nocov end

#' Strength or weighted vertex degree
#'
#' @description
Expand Down Expand Up @@ -134,21 +149,6 @@ bonpow <- function(graph, nodes = V(graph), loops = FALSE, exponent = 1, rescale
power_centrality(graph = graph, nodes = nodes, loops = loops, exponent = exponent, rescale = rescale, tol = tol, sparse = sparse)
} # nocov end

#' Kleinberg's hub and authority centrality scores.
#'
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' `authority.score()` was renamed to `authority_score()` to create a more
#' consistent API.
#' @inheritParams authority_score
#' @keywords internal
#' @export
authority.score <- function(graph, scale = TRUE, weights = NULL, options = arpack_defaults()) { # nocov start
lifecycle::deprecate_soft("2.0.0", "authority.score()", "authority_score()")
maelle marked this conversation as resolved.
Show resolved Hide resolved
authority_score(graph = graph, scale = scale, weights = weights, options = options)
} # nocov end

#' Find Bonacich alpha centrality scores of network positions
#'
#' @description
Expand Down Expand Up @@ -1105,6 +1105,7 @@ diversity <- diversity_impl
#' selected by the surfer.
#' @param options A named list, to override some ARPACK options. See
#' [arpack()] for details.
#' @inheritParams rlang::args_dots_empty
#' @return A named list with members:
#' \item{vector}{The hub or authority scores of the vertices.}
#' \item{value}{The corresponding eigenvalue of the calculated
Expand All @@ -1124,36 +1125,66 @@ diversity <- diversity_impl
#' @examples
#' ## An in-star
#' g <- make_star(10)
#' hub_score(g)$vector
#' authority_score(g)$vector
#' hits_scores(g)
#'
#' ## A ring
#' g2 <- make_ring(10)
#' hub_score(g2)$vector
#' authority_score(g2)$vector
#' hits_scores(g2)
#' @family centrality
hub_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
hits_scores <- function(graph, ..., scale=TRUE, weights=NULL, options=arpack_defaults()) {

rlang::check_dots_empty()

hub_and_authority_scores_impl(graph = graph,
scale = scale,
weights = weights,
options = options)
}

#' @title Kleinberg's authority centrality scores.
#' @rdname hub_score
#' @param options A named list, to override some ARPACK options. See
#' [arpack()] for details.
#' @export
authority_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
lifecycle::deprecate_soft("2.0.4", "authority_score()", "hits_scores()")
if (is.function(options)) {
lifecycle::deprecate_soft(
"1.6.0",
"hub_score(options = 'must be a list')",
details = c("`arpack_defaults()` is now a function, use `options = arpack_defaults()` instead of `options = arpack_defaults`.")
I("arpack_defaults"),
"arpack_defaults()",
details = c("So the function arpack_defaults(), not an object called arpack_defaults.")
)
options <- options()
options <- arpack_defaults()
}

hub_score_impl(graph = graph,
scale = scale,
weights = weights,
options = options)
scores <- hits_scores(
graph = graph,
scale = scale,
weights = weights,
options = options)
scores$hub <- NULL
rlang::set_names(scores, c("vector", "value", "options"))
}

#' @title Kleinberg's hub centrality scores.
#' @rdname hub_score
#' @param graph The input graph.
#' @param scale Logical scalar, whether to scale the result to have a maximum
#' score of one. If no scaling is used then the result vector has unit length
#' in the Euclidean norm.
#' @param weights Optional positive weight vector for calculating weighted
#' scores. If the graph has a `weight` edge attribute, then this is used
#' by default.
#' This function interprets edge weights as connection strengths. In the
#' random surfer model, an edge with a larger weight is more likely to be
#' selected by the surfer.
#' @param options A named list, to override some ARPACK options. See
#' [arpack()] for details.
#' @family centrality
#' @export
authority_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
hub_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) {
lifecycle::deprecate_soft("2.0.3", "hub_score()", "hits_scores()")
if (is.function(options)) {
lifecycle::deprecate_soft(
"1.6.0",
Expand All @@ -1164,10 +1195,13 @@ authority_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defa
options <- arpack_defaults()
}

authority_score_impl(graph = graph,
scale = scale,
weights = weights,
options = options)
scores <- hits_scores(
graph = graph,
scale = scale,
weights = weights,
options = options)
scores$authority <- NULL
rlang::set_names(scores, c("vector", "value", "options"))
}

#' The Page Rank algorithm
Expand Down
23 changes: 13 additions & 10 deletions R/games.R
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ sample_gnp <- function(n, p, directed = FALSE, loops = FALSE) {

on.exit(.Call(R_igraph_finalizer))
res <- .Call(
R_igraph_erdos_renyi_game, as.numeric(n), as.numeric(type1),
R_igraph_erdos_renyi_game_gnp, as.numeric(n),
as.numeric(p), as.logical(directed), as.logical(loops)
)

Expand Down Expand Up @@ -651,7 +651,7 @@ sample_gnm <- function(n, m, directed = FALSE, loops = FALSE) {

on.exit(.Call(R_igraph_finalizer))
res <- .Call(
R_igraph_erdos_renyi_game, as.numeric(n), as.numeric(type1),
R_igraph_erdos_renyi_game_gnm, as.numeric(n),
as.numeric(m), as.logical(directed), as.logical(loops)
)

Expand Down Expand Up @@ -716,16 +716,19 @@ gnm <- function(...) constructor_spec(sample_gnm, ...)
erdos.renyi.game <- function(n, p.or.m, type = c("gnp", "gnm"),
directed = FALSE, loops = FALSE) {
type <- igraph.match.arg(type)
type1 <- switch(type,
"gnp" = 0,
"gnm" = 1
)

on.exit(.Call(R_igraph_finalizer))
res <- .Call(
R_igraph_erdos_renyi_game, as.numeric(n), as.numeric(type1),
as.numeric(p.or.m), as.logical(directed), as.logical(loops)
)
if (type == "gnp") {
res <- .Call(
R_igraph_erdos_renyi_game_gnp, as.numeric(n),
as.numeric(p.or.m), as.logical(directed), as.logical(loops)
)
} else if (type == "gnm") {
res <- .Call(
R_igraph_erdos_renyi_game_gnm, as.numeric(n),
as.numeric(p.or.m), as.logical(directed), as.logical(loops)
)
}

if (igraph_opt("add.params")) {
res$name <- sprintf("Erdos-Renyi (%s) graph", type)
Expand Down
Loading
Loading