Skip to content
Open
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
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ URL: https://r.igraph.org/, https://igraph.org/,
BugReports: https://github.com/igraph/rigraph/issues
Depends:
methods,
R (>= 4.0.0)
R (>= 4.1.0)
Imports:
cli,
graphics,
grDevices,
lifecycle,
magrittr,
Matrix,
pkgconfig (>= 2.0.0),
rlang (>= 1.1.0),
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ S3method(unique,igraph.vs)
export("%--%")
export("%->%")
export("%<-%")
export("%>%")
export("%c%")
export("%du%")
export("%m%")
Expand Down Expand Up @@ -950,7 +949,6 @@ importFrom(graphics,
xyinch
)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(pkgconfig,
get_config,
set_config,
Expand Down
8 changes: 4 additions & 4 deletions R/adjacency.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ graph.adjacency <- function(
#' g1 <- sample(
#' x = 0:1, size = 100, replace = TRUE,
#' prob = c(0.9, 0.1)
#' ) %>%
#' matrix(ncol = 10) %>%
#' ) |>
#' matrix(ncol = 10) |>
#' graph_from_adjacency_matrix()
#'
#' g2 <- sample(
#' x = 0:5, size = 100, replace = TRUE,
#' prob = c(0.9, 0.02, 0.02, 0.02, 0.02, 0.02)
#' ) %>%
#' matrix(ncol = 10) %>%
#' ) |>
#' matrix(ncol = 10) |>
#' graph_from_adjacency_matrix(weighted = TRUE)
#' E(g2)$weight
#'
Expand Down
24 changes: 12 additions & 12 deletions R/attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ graph_attr <- function(graph, name) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_graph_attr("layout", layout_with_fr)
#' g
#' plot(g)
Expand Down Expand Up @@ -442,8 +442,8 @@ graph.attributes <- function(graph) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' set_vertex_attr("color", value = "red") %>%
#' g <- make_ring(10) |>
#' set_vertex_attr("color", value = "red") |>
#' set_vertex_attr("label", value = letters[1:10])
#' vertex_attr(g, "label")
#' vertex_attr(g)
Expand Down Expand Up @@ -528,7 +528,7 @@ vertex_attr <- function(graph, name, index = NULL) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_vertex_attr("label", value = LETTERS[1:10])
#' g
#' plot(g)
Expand Down Expand Up @@ -766,8 +766,8 @@ set_value_at <- function(value, idx, length_out) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' set_edge_attr("weight", value = 1:10) %>%
#' g <- make_ring(10) |>
#' set_edge_attr("weight", value = 1:10) |>
#' set_edge_attr("color", value = "red")
#' g
#' plot(g, edge.width = E(g)$weight)
Expand Down Expand Up @@ -852,7 +852,7 @@ edge_attr <- function(graph, name, index = NULL) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_edge_attr("label", value = LETTERS[1:10])
#' g
#' plot(g)
Expand Down Expand Up @@ -1052,8 +1052,8 @@ graph_attr_names <- function(graph) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' set_vertex_attr("name", value = LETTERS[1:10]) %>%
#' g <- make_ring(10) |>
#' set_vertex_attr("name", value = LETTERS[1:10]) |>
#' set_vertex_attr("color", value = rep("green", 10))
#' vertex_attr_names(g)
#' plot(g)
Expand Down Expand Up @@ -1082,7 +1082,7 @@ vertex_attr_names <- function(graph) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_edge_attr("label", value = letters[1:10])
#' edge_attr_names(g)
#' plot(g)
Expand Down Expand Up @@ -1149,7 +1149,7 @@ delete_graph_attr <- function(graph, name) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_vertex_attr("name", value = LETTERS[1:10])
#' vertex_attr_names(g)
#' g2 <- delete_vertex_attr(g, "name")
Expand Down Expand Up @@ -1189,7 +1189,7 @@ delete_vertex_attr <- function(graph, name) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_edge_attr("name", value = LETTERS[1:10])
#' edge_attr_names(g)
#' g2 <- delete_edge_attr(g, "name")
Expand Down
13 changes: 5 additions & 8 deletions R/centralization.R
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ centr_degree <- function(
#' @examples
#' # A BA graph is quite centralized
#' g <- sample_pa(1000, m = 4)
#' centr_degree(g, normalized = FALSE)$centralization %>%
#' `/`(centr_degree_tmax(g, loops = FALSE))
#' centr_degree(g, normalized = FALSE)$centralization /
#' centr_degree_tmax(g, loops = FALSE)
#' centr_degree(g, normalized = TRUE)$centralization
centr_degree_tmax <- function(
graph = NULL,
Expand Down Expand Up @@ -633,8 +633,7 @@ centr_betw <- function(
#' @examples
#' # A BA graph is quite centralized
#' g <- sample_pa(1000, m = 4)
#' centr_betw(g, normalized = FALSE)$centralization %>%
#' `/`(centr_betw_tmax(g))
#' centr_betw(g, normalized = FALSE)$centralization / centr_betw_tmax(g)
#' centr_betw(g, normalized = TRUE)$centralization
centr_betw_tmax <- function(
graph = NULL,
Expand Down Expand Up @@ -793,8 +792,7 @@ centr_clo <- function(
#' @examples
#' # A BA graph is quite centralized
#' g <- sample_pa(1000, m = 4)
#' centr_clo(g, normalized = FALSE)$centralization %>%
#' `/`(centr_clo_tmax(g))
#' centr_clo(g, normalized = FALSE)$centralization / centr_clo_tmax(g)
#' centr_clo(g, normalized = TRUE)$centralization
centr_clo_tmax <- function(
graph = NULL,
Expand Down Expand Up @@ -941,8 +939,7 @@ centr_eigen <- function(
#' @examples
#' # A BA graph is quite centralized
#' g <- sample_pa(1000, m = 4)
#' centr_eigen(g, normalized = FALSE)$centralization %>%
#' `/`(centr_eigen_tmax(g))
#' centr_eigen(g, normalized = FALSE)$centralization / centr_eigen_tmax(g)
#' centr_eigen(g, normalized = TRUE)$centralization
centr_eigen_tmax <- function(
graph = NULL,
Expand Down
6 changes: 3 additions & 3 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,9 @@ print.membership <- function(x, ...) print(unclass(x), ...)
#' @export
#' @examples
#' ## Compare to the correct clustering
#' g <- (make_full_graph(10) + make_full_graph(10)) %>%
#' g <- (make_full_graph(10) + make_full_graph(10)) |>
#' rewire(each_edge(p = 0.2))
#' correct <- rep(1:2, each = 10) %>% as_membership()
#' correct <- rep(1:2, each = 10) |> as_membership()
#' fc <- cluster_fast_greedy(g)
#' compare(correct, fc)
#' compare(correct, membership(fc))
Expand All @@ -701,7 +701,7 @@ as_membership <- function(x) add_class(x, "membership")
print.communities <- function(x, ...) {
noc <- if (!is.null(x$membership)) max(membership(x), 0) else NA
mod <- if (!is.null(x$modularity)) {
modularity(x) %>% format(digits = 2)
modularity(x) |> format(digits = 2)
} else {
NA_real_
}
Expand Down
21 changes: 0 additions & 21 deletions R/igraph-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,10 @@
#' @import methods
## usethis namespace: start
#' @importFrom lifecycle deprecated
#' @importFrom magrittr %>%
#' @import rlang
## usethis namespace: end
NULL

#' Magrittr's pipes
#'
#' igraph re-exports the `%>%` operator of magrittr, because
#' we find it very useful. Please see the documentation in the
#' `magrittr` package.
#'
#' @param lhs Left hand side of the pipe.
#' @param rhs Right hand side of the pipe.
#' @return Result of applying the right hand side to the
#' result of the left hand side.
#'
#' @export
#' @name %>%
#' @rdname pipe
#' @examples
#' make_ring(10) %>%
#' add_edges(c(1, 6)) %>%
#' plot()
NULL

#' The igraph package
#'
#' igraph is a library and R package for network analysis.
Expand Down
24 changes: 12 additions & 12 deletions R/interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ add.edges <- function(graph, edges, ..., attr = list()) {
#' @family functions for manipulating graph structure
#'
#' @examples
#' g <- make_empty_graph(n = 5) %>%
#' g <- make_empty_graph(n = 5) |>
#' add_edges(c(
#' 1, 2,
#' 2, 3,
#' 3, 4,
#' 4, 5
#' )) %>%
#' set_edge_attr("color", value = "red") %>%
#' )) |>
#' set_edge_attr("color", value = "red") |>
#' add_edges(c(5, 1), color = "green")
#' E(g)[[]]
#' plot(g)
Expand Down Expand Up @@ -194,9 +194,9 @@ add_edges <- function(graph, edges, ..., attr = list()) {
#'
#' @export
#' @examples
#' g <- make_empty_graph() %>%
#' add_vertices(3, color = "red") %>%
#' add_vertices(2, color = "green") %>%
#' g <- make_empty_graph() |>
#' add_vertices(3, color = "red") |>
#' add_vertices(2, color = "green") |>
#' add_edges(c(
#' 1, 2,
#' 2, 3,
Expand Down Expand Up @@ -252,11 +252,11 @@ add_vertices <- function(graph, nv, ..., attr = list()) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' delete_edges(seq(1, 9, by = 2))
#' g
#'
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' delete_edges("10|1")
#' g
#'
Expand All @@ -280,12 +280,12 @@ delete_edges <- function(graph, edges) {
#'
#' @export
#' @examples
#' g <- make_ring(10) %>%
#' g <- make_ring(10) |>
#' set_vertex_attr("name", value = LETTERS[1:10])
#' g
#' V(g)
#'
#' g2 <- delete_vertices(g, c(1, 5)) %>%
#' g2 <- delete_vertices(g, c(1, 5)) |>
#' delete_vertices("B")
#' g2
#' V(g2)
Expand Down Expand Up @@ -316,8 +316,8 @@ delete_vertices <- function(graph, v) {
#' ecount(g)
#'
#' # Number of edges in a G(n,p) graph
#' replicate(100, sample_gnp(10, 1 / 2), simplify = FALSE) %>%
#' vapply(gsize, 0) %>%
#' replicate(100, sample_gnp(10, 1 / 2), simplify = FALSE) |>
#' vapply(gsize, 0) |>
#' hist()
gsize <- function(graph) {
ecount_impl(
Expand Down
Loading
Loading