diff --git a/NEWS.md b/NEWS.md index 7c0ee8bbb83..8464c0a9564 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,13 @@ # igraph 2.3.3.9022 +## Breaking changes (future) + +- The default value of the `mode` parameter will change from `"all"` to `"out"` in a future version for the following functions: `distances()`, `degree()`, `strength()`, `eccentricity()`, `radius()`, `graph_center()`, `ego()`, `ego_size()`, and `make_ego_graph()`. + This change makes the default behavior more intuitive by respecting edge directions in directed graphs instead of ignoring them. + A deprecation warning is now issued when these functions are called on directed graphs without explicitly specifying the `mode` parameter. + To prepare for this change and avoid warnings, please specify `mode` explicitly in your code. + ## Bug fixes - Use canonical `structure()` attribute names (#2755). diff --git a/R/centrality.R b/R/centrality.R index b874c4e401e..eaa5f5b246c 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -1515,6 +1515,18 @@ strength <- function( } # END GENERATED ARG_HANDLE + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "strength(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + strength_impl( graph = graph, vids = vids, diff --git a/R/embedding.R b/R/embedding.R index 626d9db1d0c..9f5e9a91b05 100644 --- a/R/embedding.R +++ b/R/embedding.R @@ -109,7 +109,7 @@ embed_adjacency_matrix <- function( weights = NULL, which = c("lm", "la", "sa"), scaled = TRUE, - cvec = strength(graph, weights = weights) / (vcount(graph) - 1), + cvec = strength(graph, weights = weights, mode = "all") / (vcount(graph) - 1), options = arpack_defaults() ) { # BEGIN GENERATED ARG_HANDLE: embed_adjacency_matrix, do not edit, see tools/generate-migrations.R diff --git a/R/paths.R b/R/paths.R index 7931093f6ee..f01e5886f73 100644 --- a/R/paths.R +++ b/R/paths.R @@ -326,6 +326,18 @@ eccentricity <- function( } } + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "eccentricity(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + eccentricity_dijkstra_impl( graph = graph, vids = vids, @@ -384,6 +396,18 @@ radius <- function( } } + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "radius(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + radius_dijkstra_impl( graph = graph, weights = weights, @@ -423,6 +447,18 @@ graph_center <- function( weights = NULL, mode = c("all", "out", "in", "total") ) { + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "graph_center(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + graph_center_dijkstra_impl( graph = graph, weights = weights, diff --git a/R/structural-properties.R b/R/structural-properties.R index 578eed4bbc3..7d0f18708fe 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -1063,6 +1063,19 @@ degree <- function( # END GENERATED ARG_HANDLE ensure_igraph(graph) + + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "degree(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + v <- as_igraph_vs(graph, v) mode <- igraph_match_arg(mode) @@ -1402,6 +1415,18 @@ distances <- function( ensure_igraph(graph) + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "distances(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + # make sure that the lower-level function in C gets mode == "out" # unconditionally when the graph is undirected; this is used for # the selection of Johnson's algorithm in automatic mode @@ -2550,6 +2575,19 @@ ego_size <- function( # END GENERATED ARG_HANDLE ensure_igraph(graph) + + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "ego_size(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) mindist <- as.numeric(mindist) @@ -2688,6 +2726,19 @@ ego <- function( # END GENERATED ARG_HANDLE ensure_igraph(graph) + + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "ego(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) mindist <- as.numeric(mindist) @@ -2747,6 +2798,19 @@ make_ego_graph <- function( # END GENERATED ARG_HANDLE ensure_igraph(graph) + + # Warn about upcoming change in default mode parameter + if (missing(mode) && is_directed(graph)) { + lifecycle::deprecate_soft( + "2.1.0", + "make_ego_graph(mode =)", + details = paste( + "The default value of `mode` will change from \"all\" to \"out\" in a future version.", + "Please specify `mode` explicitly to avoid this warning and ensure consistent behavior." + ) + ) + } + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1L, "in" = 2L, "all" = 3L) mindist <- as.numeric(mindist) diff --git a/man/cluster_leiden.Rd b/man/cluster_leiden.Rd index cb4b00aacef..f417aa50397 100644 --- a/man/cluster_leiden.Rd +++ b/man/cluster_leiden.Rd @@ -106,7 +106,7 @@ specify any \code{vertex_weights}, the correct vertex weights and scaling of \code{objective_function} argument. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Community.html#igraph_community_leiden}{\code{community_leiden()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Community.html#igraph_community_leiden}{\code{community_leiden()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/degree.Rd b/man/degree.Rd index 5c26929cc47..f094734e2df 100644 --- a/man/degree.Rd +++ b/man/degree.Rd @@ -69,7 +69,7 @@ The degree of a vertex is its most basic structural property, the number of its adjacent edges. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_degree}{\code{degree()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_maxdegree}{\code{maxdegree()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_mean_degree}{\code{mean_degree()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_degree}{\code{degree()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_maxdegree}{\code{maxdegree()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_mean_degree}{\code{mean_degree()}} } \examples{ diff --git a/man/degree.distribution.Rd b/man/degree.distribution.Rd index 69d71e21734..588b62854ac 100644 --- a/man/degree.distribution.Rd +++ b/man/degree.distribution.Rd @@ -21,7 +21,7 @@ be calculated.} consistent API. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_degree}{\code{degree()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_degree}{\code{degree()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} } \keyword{internal} diff --git a/man/eccentricity.Rd b/man/eccentricity.Rd index aded3cc2cf3..d9c69356a4a 100644 --- a/man/eccentricity.Rd +++ b/man/eccentricity.Rd @@ -49,7 +49,7 @@ This implementation ignores vertex pairs that are in different components. Isolate vertices have eccentricity zero. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_eccentricity_dijkstra}{\code{eccentricity_dijkstra()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_eccentricity_dijkstra}{\code{eccentricity_dijkstra()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/ego.Rd b/man/ego.Rd index 0a92929bb2e..b78d064742b 100644 --- a/man/ego.Rd +++ b/man/ego.Rd @@ -125,7 +125,7 @@ the vertex, edge and graph attributes. all other vertices in its neighborhood. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_connect_neighborhood}{\code{connect_neighborhood()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_connect_neighborhood}{\code{connect_neighborhood()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} } \examples{ diff --git a/man/embed_adjacency_matrix.Rd b/man/embed_adjacency_matrix.Rd index f7c3abd2e98..4fd3e3819a6 100644 --- a/man/embed_adjacency_matrix.Rd +++ b/man/embed_adjacency_matrix.Rd @@ -11,7 +11,7 @@ embed_adjacency_matrix( weights = NULL, which = c("lm", "la", "sa"), scaled = TRUE, - cvec = strength(graph, weights = weights)/(vcount(graph) - 1), + cvec = strength(graph, weights = weights, mode = "all")/(vcount(graph) - 1), options = arpack_defaults() ) } @@ -92,7 +92,7 @@ sqrt(D[no])}. (For undirected graphs \eqn{U=V}, so it is enough to keep one of them.) } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Embedding.html#igraph_adjacency_spectral_embedding}{\code{adjacency_spectral_embedding()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Embedding.html#igraph_adjacency_spectral_embedding}{\code{adjacency_spectral_embedding()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/graph.neighborhood.Rd b/man/graph.neighborhood.Rd index 3a52ea1951c..cc554ea899e 100644 --- a/man/graph.neighborhood.Rd +++ b/man/graph.neighborhood.Rd @@ -37,7 +37,7 @@ argument is ignored for undirected graphs.} consistent API. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}} } \keyword{internal} diff --git a/man/graph.strength.Rd b/man/graph.strength.Rd index d4cc8e6242d..f1b67eceb91 100644 --- a/man/graph.strength.Rd +++ b/man/graph.strength.Rd @@ -36,7 +36,7 @@ attribute, then this is used by default. If the graph does not have a consistent API. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \keyword{internal} diff --git a/man/graph_center.Rd b/man/graph_center.Rd index 501dda469bb..94c66029481 100644 --- a/man/graph_center.Rd +++ b/man/graph_center.Rd @@ -33,7 +33,7 @@ The vertex IDs of the central vertices. The center of a graph is the set of its vertices with minimal eccentricity. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_graph_center_dijkstra}{\code{graph_center_dijkstra()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_graph_center_dijkstra}{\code{graph_center_dijkstra()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/local_scan.Rd b/man/local_scan.Rd index 17a89226881..d2bbba684bb 100644 --- a/man/local_scan.Rd +++ b/man/local_scan.Rd @@ -84,7 +84,7 @@ information, and applying \code{FUN} on these neighborhoods in \code{graph.them}. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_neighborhood_ecount}{\code{local_scan_neighborhood_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0_them}{\code{local_scan_0_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount_them}{\code{local_scan_1_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount_them}{\code{local_scan_k_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0}{\code{local_scan_0()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount}{\code{local_scan_1_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount}{\code{local_scan_k_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_induced_subgraph}{\code{induced_subgraph()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_neighborhood_ecount}{\code{local_scan_neighborhood_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0_them}{\code{local_scan_0_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount_them}{\code{local_scan_1_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount_them}{\code{local_scan_k_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0}{\code{local_scan_0()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount}{\code{local_scan_1_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount}{\code{local_scan_k_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_induced_subgraph}{\code{induced_subgraph()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/neighborhood.size.Rd b/man/neighborhood.size.Rd index f4d6722866c..83b04c720ac 100644 --- a/man/neighborhood.size.Rd +++ b/man/neighborhood.size.Rd @@ -37,7 +37,7 @@ argument is ignored for undirected graphs.} consistent API. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}} } \keyword{internal} diff --git a/man/radius.Rd b/man/radius.Rd index d9bd5176321..04ed4f8e150 100644 --- a/man/radius.Rd +++ b/man/radius.Rd @@ -40,7 +40,7 @@ This implementation ignores vertex pairs that are in different components. Isolated vertices have eccentricity zero. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_radius_dijkstra}{\code{radius_dijkstra()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_radius_dijkstra}{\code{radius_dijkstra()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/scan_stat.Rd b/man/scan_stat.Rd index 2a6a45e84be..7c854c19949 100644 --- a/man/scan_stat.Rd +++ b/man/scan_stat.Rd @@ -45,7 +45,7 @@ each graph and each vertex, and then normalizing across the vertices and across the time steps. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_neighborhood_ecount}{\code{local_scan_neighborhood_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0_them}{\code{local_scan_0_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount_them}{\code{local_scan_1_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount_them}{\code{local_scan_k_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0}{\code{local_scan_0()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount}{\code{local_scan_1_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount}{\code{local_scan_k_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_induced_subgraph}{\code{induced_subgraph()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_neighborhood_ecount}{\code{local_scan_neighborhood_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0_them}{\code{local_scan_0_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount_them}{\code{local_scan_1_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount_them}{\code{local_scan_k_ecount_them()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_0}{\code{local_scan_0()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_1_ecount}{\code{local_scan_1_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_local_scan_k_ecount}{\code{local_scan_k_ecount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_induced_subgraph}{\code{induced_subgraph()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/man/strength.Rd b/man/strength.Rd index 3dfd73932ef..d9cdb661226 100644 --- a/man/strength.Rd +++ b/man/strength.Rd @@ -39,7 +39,7 @@ A numeric vector giving the strength of the vertices. Summing up the edge weights of the adjacent edges for each vertex. } \section{Related documentation in the C library}{ -\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} +\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_strength}{\code{strength()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_is_directed}{\code{is_directed()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_edges}{\code{edges()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_get_eids}{\code{get_eids()}}, \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_ecount}{\code{ecount()}} } \examples{ diff --git a/tests/testthat/test-conversion.R b/tests/testthat/test-conversion.R index fb1ad991383..cafddd58426 100644 --- a/tests/testthat/test-conversion.R +++ b/tests/testthat/test-conversion.R @@ -2,19 +2,19 @@ test_that("as_directed works", { igraph_local_seed(42) gnp_undirected <- sample_gnp(100, 2 / 100) gnp_mutual <- as_directed(gnp_undirected, mode = "mutual") - expect_equal(degree(gnp_undirected), degree(gnp_mutual) / 2) + expect_equal(degree(gnp_undirected), degree(gnp_mutual, mode = "all") / 2) expect_isomorphic(gnp_undirected, as_undirected(gnp_mutual)) gnp_arbitrary <- as_directed(gnp_undirected, mode = "arbitrary") - expect_equal(degree(gnp_undirected), degree(gnp_arbitrary)) + expect_equal(degree(gnp_undirected), degree(gnp_arbitrary, mode = "all")) expect_isomorphic(gnp_undirected, as_undirected(gnp_arbitrary)) gnp_random <- as_directed(gnp_undirected, mode = "random") - expect_equal(degree(gnp_undirected), degree(gnp_random)) + expect_equal(degree(gnp_undirected), degree(gnp_random, mode = "all")) expect_isomorphic(gnp_undirected, as_undirected(gnp_random)) gnp_acyclic <- as_directed(gnp_undirected, mode = "acyclic") - expect_equal(degree(gnp_undirected), degree(gnp_acyclic)) + expect_equal(degree(gnp_undirected), degree(gnp_acyclic, mode = "all")) expect_isomorphic(gnp_undirected, as_undirected(gnp_acyclic)) }) diff --git a/tests/testthat/test-embedding.R b/tests/testthat/test-embedding.R index 16be97fb8ad..1f71749a46e 100644 --- a/tests/testthat/test-embedding.R +++ b/tests/testthat/test-embedding.R @@ -7,7 +7,12 @@ test_that("embed_adjacency_matrix -- Undirected, unweighted case works", { no <- 7 A <- g[] A <- A + - 1 / 2 * as(Matrix::Matrix(diag(degree(g)), doDiag = FALSE), "generalMatrix") + 1 / + 2 * + as( + Matrix::Matrix(diag(degree(g, mode = "all")), doDiag = FALSE), + "generalMatrix" + ) ss <- eigen(A) U <- standardize_eigen_signs(ss$vectors) @@ -17,14 +22,14 @@ test_that("embed_adjacency_matrix -- Undirected, unweighted case works", { g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_la <- embed_adjacency_matrix( g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -40,14 +45,14 @@ test_that("embed_adjacency_matrix -- Undirected, unweighted case works", { g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_lm <- embed_adjacency_matrix( g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -66,14 +71,14 @@ test_that("embed_adjacency_matrix -- Undirected, unweighted case works", { g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_sa <- embed_adjacency_matrix( g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -94,7 +99,12 @@ test_that("embed_adjacency_matrix -- Undirected, weighted case works", { no <- 3 A <- g[] A <- A + - 1 / 2 * as(Matrix::Matrix(diag(degree(g)), doDiag = FALSE), "generalMatrix") + 1 / + 2 * + as( + Matrix::Matrix(diag(degree(g, mode = "all")), doDiag = FALSE), + "generalMatrix" + ) ss <- eigen(A) U <- standardize_eigen_signs(ss$vectors) @@ -104,14 +114,14 @@ test_that("embed_adjacency_matrix -- Undirected, weighted case works", { g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_la <- embed_adjacency_matrix( g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -127,14 +137,14 @@ test_that("embed_adjacency_matrix -- Undirected, weighted case works", { g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_lm <- embed_adjacency_matrix( g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -153,14 +163,14 @@ test_that("embed_adjacency_matrix -- Undirected, weighted case works", { g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_sa <- embed_adjacency_matrix( g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -178,7 +188,12 @@ test_that("embed_adjacency_matrix -- Directed, unweighted case works", { no <- 3 A <- g[] A <- A + - 1 / 2 * as(Matrix::Matrix(diag(degree(g)), doDiag = FALSE), "generalMatrix") + 1 / + 2 * + as( + Matrix::Matrix(diag(degree(g, mode = "all")), doDiag = FALSE), + "generalMatrix" + ) ss <- svd(A) U <- standardize_eigen_signs(ss$u) @@ -190,14 +205,14 @@ test_that("embed_adjacency_matrix -- Directed, unweighted case works", { g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_la <- embed_adjacency_matrix( g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -218,14 +233,14 @@ test_that("embed_adjacency_matrix -- Directed, unweighted case works", { g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_lm <- embed_adjacency_matrix( g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -246,14 +261,14 @@ test_that("embed_adjacency_matrix -- Directed, unweighted case works", { g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_sa <- embed_adjacency_matrix( g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -279,7 +294,12 @@ test_that("embed_adjacency_matrix -- Directed, weighted case works", { no <- 3 A <- g[] A <- A + - 1 / 2 * as(Matrix::Matrix(diag(degree(g)), doDiag = FALSE), "generalMatrix") + 1 / + 2 * + as( + Matrix::Matrix(diag(degree(g, mode = "all")), doDiag = FALSE), + "generalMatrix" + ) ss <- svd(A) U <- standardize_eigen_signs(ss$u) @@ -291,14 +311,14 @@ test_that("embed_adjacency_matrix -- Directed, weighted case works", { g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_la <- embed_adjacency_matrix( g, no = no, which = "la", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -317,14 +337,14 @@ test_that("embed_adjacency_matrix -- Directed, weighted case works", { g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_lm <- embed_adjacency_matrix( g, no = no, which = "lm", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -343,14 +363,14 @@ test_that("embed_adjacency_matrix -- Directed, weighted case works", { g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = TRUE ) as_sa <- embed_adjacency_matrix( g, no = no, which = "sa", - cvec = degree(g) / 2, + cvec = degree(g, mode = "all") / 2, scaled = FALSE ) @@ -398,7 +418,10 @@ test_that("embed_laplacian_matrix -- Undirected, unweighted, D-A case works", { g <- sample_gnm(10, 20, directed = FALSE) no <- 3 - A <- as(Matrix::Matrix(diag(degree(g)), doDiag = FALSE), "generalMatrix") - + A <- as( + Matrix::Matrix(diag(degree(g, mode = "all")), doDiag = FALSE), + "generalMatrix" + ) - g[] ss <- eigen(A) @@ -497,7 +520,7 @@ test_that("embed_laplacian_matrix -- Undirected, unweighted, DAD case works", { g <- sample_gnm(10, 20, directed = FALSE) no <- 3 - D12 <- diag(1 / sqrt(degree(g))) + D12 <- diag(1 / sqrt(degree(g, mode = "all"))) A <- D12 %*% g[] %*% D12 ss <- eigen(A) @@ -596,7 +619,7 @@ test_that("embed_laplacian_matrix -- Undirected, unweighted, I-DAD case works", g <- sample_gnm(10, 20, directed = FALSE) no <- 3 - D12 <- diag(1 / sqrt(degree(g))) + D12 <- diag(1 / sqrt(degree(g, mode = "all"))) A <- diag(vcount(g)) - D12 %*% g[] %*% D12 ss <- eigen(A) @@ -793,7 +816,7 @@ test_that("embed_laplacian_matrix -- Undirected, unweighted, DAD case works", { g <- sample_gnm(10, 20, directed = FALSE) no <- 3 - D12 <- diag(1 / sqrt(degree(g))) + D12 <- diag(1 / sqrt(degree(g, mode = "all"))) A <- D12 %*% g[] %*% D12 ss <- eigen(A) @@ -893,7 +916,7 @@ test_that("embed_laplacian_matrix -- Undirected, unweighted, I-DAD case works", g <- sample_gnm(10, 20, directed = FALSE) no <- 3 - D12 <- diag(1 / sqrt(degree(g))) + D12 <- diag(1 / sqrt(degree(g, mode = "all"))) A <- diag(vcount(g)) - D12 %*% g[] %*% D12 ss <- eigen(A) diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index f2034ffd21e..8c9b6ee49c1 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -343,15 +343,15 @@ test_that("sample_pa can start from a graph", { expect_ecount(g_pa1, 5) expect_vcount(g_pa1, 10) - is_degree_zero <- (degree(g_pa1) == 0) + is_degree_zero <- (degree(g_pa1, mode = "all") == 0) expect_true(sum(is_degree_zero) %in% 0:4) # 2 3 4 5 6 7 8 10 # 25 302 1820 2563 3350 1093 816 31 - is_degree_one <- (degree(g_pa1) == 1) + is_degree_one <- (degree(g_pa1, mode = "all") == 1) expect_true(sum(is_degree_one) %in% c(2:8, 10L)) # 0 1 2 3 4 # 879 2271 5289 1532 29 - is_degree_two_or_three <- (degree(g_pa1) %in% 2:3) + is_degree_two_or_three <- (degree(g_pa1, mode = "all") %in% 2:3) expect_true(sum(is_degree_two_or_three) %in% 0:4) g_pa2 <- sample_pa(10, m = 1, algorithm = "bag", start.graph = make_star(10)) diff --git a/tests/testthat/test-paths.R b/tests/testthat/test-paths.R index 282643899db..18958c0877e 100644 --- a/tests/testthat/test-paths.R +++ b/tests/testthat/test-paths.R @@ -2,7 +2,7 @@ test_that("radius() works", { igraph_local_seed(42) g <- make_tree(10, 2) - expect_equal(radius(g), 3) + expect_equal(radius(g, mode = "all"), 3) expect_equal(radius(g, mode = "in"), 0) expect_equal(radius(g, mode = "out"), 0) }) @@ -27,7 +27,7 @@ test_that("eccentricity() works", { igraph_local_seed(42) g <- make_tree(10, 2) - expect_equal(eccentricity(g), c(3, 3, 4, 4, 4, 5, 5, 5, 5, 5)) + expect_equal(eccentricity(g, mode = "all"), c(3, 3, 4, 4, 4, 5, 5, 5, 5, 5)) expect_equal(eccentricity(g, mode = "in"), c(0, 1, 1, 2, 2, 2, 2, 3, 3, 3)) expect_equal(eccentricity(g, mode = "out"), c(3, 2, 1, 1, 1, 0, 0, 0, 0, 0)) }) @@ -51,7 +51,7 @@ test_that("eccentricity() works -- lifecycle", { test_that("graph_center() works", { igraph_local_seed(42) g <- make_tree(100, 7) - expect_equal(as.numeric(graph_center(g)), c(1, 2)) + expect_equal(as.numeric(graph_center(g, mode = "all")), c(1, 2)) expect_equal(as.numeric(graph_center(g, mode = "in")), 1) expect_equal(as.numeric(graph_center(g, mode = "out")), 16:100) })