Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
61 changes: 60 additions & 1 deletion R/components.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ component_distribution <- function(
#' Creates a separate graph for each connected component of a graph.
#'
#' @param graph The original graph.
#' @inheritParams rlang::args_dots_empty
#' @param mode Character constant giving the type of the components, wither
#' `weak` for weakly connected components or `strong` for strongly
#' connected components.
Expand Down Expand Up @@ -198,10 +199,41 @@ component_distribution <- function(
#'
decompose <- function(
graph,
...,
mode = c("weak", "strong"),
max.comps = NA,
min.vertices = 0
) {
# BEGIN GENERATED ARG_HANDLE: decompose, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(
mode = mode,
max.comps = max.comps,
min.vertices = min.vertices
),
recover_new = c("mode", "max.comps", "min.vertices"),
recover_old = c("mode", "max.comps", "min.vertices"),
match_names = c("mode", "max.comps", "min.vertices"),
match_to = c("mode", "max.comps", "min.vertices"),
defaults = list(
mode = c("weak", "strong"),
max.comps = NA,
min.vertices = 0
),
head_args = c("graph"),
fn_name = "decompose"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

ensure_igraph(graph)
mode <- igraph_match_arg(mode)

Expand Down Expand Up @@ -394,8 +426,35 @@ is_biconnected <- function(graph) {


#' @rdname components
#' @inheritParams rlang::args_dots_empty
#' @export
largest_component <- function(graph, mode = c("weak", "strong")) {
largest_component <- function(
graph,
...,
mode = c("weak", "strong")
) {
# BEGIN GENERATED ARG_HANDLE: largest_component, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(mode = mode),
recover_new = c("mode"),
recover_old = c("mode"),
match_names = c("mode"),
match_to = c("mode"),
defaults = list(mode = c("weak", "strong")),
head_args = c("graph"),
fn_name = "largest_component"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

ensure_igraph(graph)

comps <- components(graph, mode = mode)
Expand Down
1 change: 1 addition & 0 deletions R/cycles.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#' a specific cycle.
#'
#' @param graph The input graph.
#' @inheritParams rlang::args_dots_empty
#' @param mode Character constant specifying how to handle directed graphs.
#' `out` follows edge directions, `in` follows edges in the reverse direction,
#' and `all` ignores edge directions. Ignored in undirected graphs.
Expand Down
30 changes: 29 additions & 1 deletion R/games.R
Original file line number Diff line number Diff line change
Expand Up @@ -2135,9 +2135,37 @@ asym_pref <- function(
## -----------------------------------------------------------------

#' @rdname ego
#' @inheritParams rlang::args_dots_empty
#' @export
#' @family functions for manipulating graph structure
connect <- function(graph, order, mode = c("all", "out", "in", "total")) {
connect <- function(
graph,
order,
...,
mode = c("all", "out", "in", "total")
) {
# BEGIN GENERATED ARG_HANDLE: connect, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(mode = mode),
recover_new = c("mode"),
recover_old = c("mode"),
match_names = c("mode"),
match_to = c("mode"),
defaults = list(mode = c("all", "out", "in", "total")),
head_args = c("graph", "order"),
fn_name = "connect"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

ensure_igraph(graph)
mode <- igraph_match_arg(mode)

Expand Down
53 changes: 52 additions & 1 deletion R/paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ is.dag <- function(graph) {
#' @param graph The input graph.
#' @param from The source vertex.
#' @param to The target vertex of vertices. Defaults to all vertices.
#' @inheritParams rlang::args_dots_empty
#' @param mode Character constant, gives whether the shortest paths to or
#' from the given vertices should be calculated for directed graphs. If
#' `out` then the shortest paths *from* the vertex, if `in`
Expand All @@ -110,9 +111,32 @@ all_simple_paths <- function(
graph,
from,
to = V(graph),
...,
mode = c("out", "in", "all", "total"),
cutoff = -1
) {
# BEGIN GENERATED ARG_HANDLE: all_simple_paths, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(mode = mode, cutoff = cutoff),
recover_new = c("mode", "cutoff"),
recover_old = c("mode", "cutoff"),
match_names = c("mode", "cutoff"),
match_to = c("mode", "cutoff"),
defaults = list(mode = c("out", "in", "all", "total"), cutoff = -1),
head_args = c("graph", "from", "to"),
fn_name = "all_simple_paths"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

## Argument checks
ensure_igraph(graph)

Expand Down Expand Up @@ -407,10 +431,37 @@ graph_center <- function(
}

#' @rdname distances
#' @inheritParams rlang::args_dots_empty
#' @param directed Whether to consider directed paths in directed graphs,
#' this argument is ignored for undirected graphs.
#' @export
distance_table <- function(graph, directed = TRUE) {
distance_table <- function(
graph,
...,
directed = TRUE
) {
# BEGIN GENERATED ARG_HANDLE: distance_table, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(directed = directed),
recover_new = c("directed"),
recover_old = c("directed"),
match_names = c("directed"),
match_to = c("directed"),
defaults = list(directed = TRUE),
head_args = c("graph"),
fn_name = "distance_table"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

path_length_hist_impl(
graph = graph,
directed = directed
Expand Down
Loading