From 13b22a42dfe39d1813645a2fe7b9744270781466 Mon Sep 17 00:00:00 2001 From: maksymis <32574056+maksymiuks@users.noreply.github.com> Date: Fri, 9 May 2025 13:24:43 +0200 Subject: [PATCH] Add backwards compatibility for igraph subgraph --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ R/task_graph.R | 9 ++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c17a415..35bd1e4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: checked Title: Systematically Run R CMD Checks -Version: 0.2.8 +Version: 0.2.8.9000 Authors@R: c( person( diff --git a/NEWS.md b/NEWS.md index 44b2e40..c6b42e9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# checked (devel) + +* Add `igraph_subgraph_from_edges` wrapper to used work around deprecation + messages and alternate between `igraph::subgraph.edges` and + `igraph::subgraph_from_edges` depending on the `igraph` version. + # checked 0.2.8 * Unify notes, warnings and errors are internally stored when generating diff --git a/R/task_graph.R b/R/task_graph.R index 52ccff8..cc80f21 100644 --- a/R/task_graph.R +++ b/R/task_graph.R @@ -211,7 +211,7 @@ task_graph_sort <- function(g) { # use only strong dependencies to prioritize by topology (leafs first) strong_edges <- igraph::E(g)[igraph::E(g)$type %in% DEP_STRONG] - g_strong <- igraph::subgraph_from_edges(g, strong_edges, delete.vertices = FALSE) + g_strong <- igraph_subgraph_from_edges(g, strong_edges, delete.vertices = FALSE) topo <- igraph::topo_sort(g_strong, mode = "in") priority_topo <- integer(length(g)) priority_topo[match(topo$name, igraph::V(g)$name)] <- rev(seq_along(topo)) @@ -418,3 +418,10 @@ is_package_satisfied <- function(v, lib.loc) { # nolint object_name_linter } } +igraph_subgraph_from_edges <- function(...) { + if (packageVersion("igraph") < "2.1.0") { + igraph::subgraph.edges(...) + } else { + igraph::subgraph_from_edges(...) + } +}