Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
68c8ba1
added config
schochastics Jun 10, 2025
2107e74
chore: Auto-update from GitHub Actions
schochastics Jun 10, 2025
203df48
first batch of reformatting
schochastics Jun 10, 2025
da0908f
cliques.R
schochastics Jun 10, 2025
e4cdf7f
cocitation
schochastics Jun 10, 2025
5cfbcd1
cohesive.blocks
schochastics Jun 10, 2025
11ee680
community
schochastics Jun 10, 2025
ca157a1
console
schochastics Jun 10, 2025
1e8b280
conversion
schochastics Jun 10, 2025
2717bd4
decomposition
schochastics Jun 10, 2025
8455f67
degseq
schochastics Jun 10, 2025
48cef3b
demo
schochastics Jun 10, 2025
8f89961
foreign
schochastics Jun 10, 2025
35720b7
flow
schochastics Jun 10, 2025
081b671
fit
schochastics Jun 10, 2025
ff0c4d2
epi
schochastics Jun 10, 2025
36e78aa
games
schochastics Jun 10, 2025
92bf6f3
glet
schochastics Jun 10, 2025
dd8645f
has
schochastics Jun 10, 2025
11857c6
hrg
schochastics Jun 10, 2025
cc5b62d
incidence
schochastics Jun 10, 2025
b7b35c0
indexing
schochastics Jun 10, 2025
2b21c7c
interface
schochastics Jun 10, 2025
d30e64f
layout
schochastics Jun 10, 2025
07e72ed
palette
schochastics Jun 10, 2025
d99195d
make
schochastics Jun 10, 2025
e7583dc
mst
schochastics Jun 10, 2025
a0d0f36
motifs
schochastics Jun 10, 2025
52da86f
operators
schochastics Jun 10, 2025
698193b
other
schochastics Jun 10, 2025
f80a338
printr
schochastics Jun 10, 2025
d6ee979
print
schochastics Jun 10, 2025
9cc9eeb
plot.shapes
schochastics Jun 10, 2025
fc065e5
plot
schochastics Jun 10, 2025
71d0801
plot.common
schochastics Jun 10, 2025
d1a48ed
paths
schochastics Jun 10, 2025
b42b6b8
par
schochastics Jun 10, 2025
5abd33e
random_walk
schochastics Jun 10, 2025
0e9e816
rewire
schochastics Jun 10, 2025
040354d
scan
schochastics Jun 10, 2025
a0664aa
sgm
schochastics Jun 10, 2025
8cbb888
similarities
schochastics Jun 10, 2025
5095b01
stochastic_matrix
schochastics Jun 10, 2025
77ad9e4
structural-properties
schochastics Jun 10, 2025
cea2e31
structure.info
schochastics Jun 10, 2025
46b8fa2
tkplot
schochastics Jun 10, 2025
d416282
topology
schochastics Jun 10, 2025
beb6623
trees
schochastics Jun 10, 2025
9b66165
triangles
schochastics Jun 10, 2025
0143c66
utils-assert-args
schochastics Jun 10, 2025
85b15bf
utils-s3
schochastics Jun 10, 2025
abcb8cf
utils
schochastics Jun 10, 2025
b50493f
reformatted with make_graph as skip
schochastics Jun 12, 2025
fff4080
foreign
schochastics Jun 12, 2025
8cd1081
added edge to exclude
schochastics Jun 12, 2025
8119e16
reformat plot with c skipped
schochastics Jun 12, 2025
142f450
more c in print
schochastics Jun 12, 2025
b8213e9
Discard changes to R/utils-s3.R
schochastics Jun 13, 2025
f1c1f38
added utils-s3.R to exclude
schochastics Jun 13, 2025
ee2cf94
Merge branch 'main' into f-air
schochastics Jun 13, 2025
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
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
^vendor-one\.sh$
^patch$
^src/deps\.mk$
^[\.]?air\.toml$
^\.vscode$
^man/dot-igraph.progress\.Rd$
^man/dot-igraph.status\.Rd$
^man/dot-extract_constructor_and_modifiers\.Rd$
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/version_number
igraph.Rcheck/
.venv/
.vscode/
.Rproj.user
/configure~
/src/build/
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"Posit.air-vscode"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
}
}
110 changes: 82 additions & 28 deletions R/adjacency.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,28 @@
#' @inheritParams graph_from_adjacency_matrix
#' @keywords internal
#' @export
graph.adjacency <- function(adjmatrix, mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"), weighted = NULL, diag = TRUE, add.colnames = NULL, add.rownames = NA) { # nocov start
lifecycle::deprecate_soft("2.0.0", "graph.adjacency()", "graph_from_adjacency_matrix()")
graph_from_adjacency_matrix(adjmatrix = adjmatrix, mode = mode, weighted = weighted, diag = diag, add.colnames = add.colnames, add.rownames = add.rownames)
graph.adjacency <- function(
adjmatrix,
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
weighted = NULL,
diag = TRUE,
add.colnames = NULL,
add.rownames = NA
) {
# nocov start
lifecycle::deprecate_soft(
"2.0.0",
"graph.adjacency()",
"graph_from_adjacency_matrix()"
)
graph_from_adjacency_matrix(
adjmatrix = adjmatrix,
mode = mode,
weighted = weighted,
diag = diag,
add.colnames = add.colnames,
add.rownames = add.rownames
)
} # nocov end

## ----------------------------------------------------------------
Expand Down Expand Up @@ -254,13 +273,22 @@ graph.adjacency <- function(adjmatrix, mode = c("directed", "undirected", "max",
#' summary(g10)
#'
#' @export
graph_from_adjacency_matrix <- function(adjmatrix,
mode = c(
"directed", "undirected", "max",
"min", "upper", "lower", "plus"
),
weighted = NULL, diag = TRUE,
add.colnames = NULL, add.rownames = NA) {
graph_from_adjacency_matrix <- function(
adjmatrix,
mode = c(
"directed",
"undirected",
"max",
"min",
"upper",
"lower",
"plus"
),
weighted = NULL,
diag = TRUE,
add.colnames = NULL,
add.rownames = NA
) {
ensure_no_na(adjmatrix, "adjacency matrix")
mode <- igraph.match.arg(mode)

Expand All @@ -284,9 +312,19 @@ graph_from_adjacency_matrix <- function(adjmatrix,
}

if (inherits(adjmatrix, "Matrix")) {
res <- graph.adjacency.sparse(adjmatrix, mode = mode, weighted = weighted, diag = diag)
res <- graph.adjacency.sparse(
adjmatrix,
mode = mode,
weighted = weighted,
diag = diag
)
} else {
res <- graph.adjacency.dense(adjmatrix, mode = mode, weighted = weighted, diag = diag)
res <- graph.adjacency.dense(
adjmatrix,
mode = mode,
weighted = weighted,
diag = diag
)
}

## Add columns and row names as attributes
Expand Down Expand Up @@ -316,8 +354,9 @@ graph_from_adjacency_matrix <- function(adjmatrix,
}
}

if (!is.na(add.rownames) && !is.na(add.colnames) &&
add.rownames == add.colnames) {
if (
!is.na(add.rownames) && !is.na(add.colnames) && add.rownames == add.colnames
) {
cli::cli_warn("Same attribute for columns and rows, row names are ignored")
add.rownames <- NA
}
Expand Down Expand Up @@ -348,14 +387,18 @@ is_symmetric <- function(x) {
#' @param ... Passed to `graph_from_adjacency_matrix()`.
#' @family adjacency
#' @export
from_adjacency <- function(...) constructor_spec(graph_from_adjacency_matrix, ...)
from_adjacency <- function(...) {
constructor_spec(graph_from_adjacency_matrix, ...)
}

graph.adjacency.dense <- function(
adjmatrix,
adjmatrix,
mode,
weighted = NULL,
diag = c("once", "twice", "ignore")
) {
mode <- switch(
mode,
weighted = NULL,
diag = c("once", "twice", "ignore")) {
mode <- switch(mode,
"directed" = 0L,
"undirected" = 1L,
"upper" = 2L,
Expand All @@ -369,11 +412,7 @@ graph.adjacency.dense <- function(
diag <- ifelse(diag, "once", "ignore")
}
diag <- igraph.match.arg(diag)
diag <- switch(diag,
"ignore" = 0L,
"twice" = 1L,
"once" = 2L
)
diag <- switch(diag, "ignore" = 0L, "twice" = 1L, "once" = 2L)

if (nrow(adjmatrix) != ncol(adjmatrix)) {
stop("Adjacency matrices must be square.")
Expand Down Expand Up @@ -421,13 +460,22 @@ pmin_AB <- function(A, B) {
A
}

graph.adjacency.sparse <- function(adjmatrix, mode, weighted = NULL, diag = TRUE, call = rlang::caller_env()) {
graph.adjacency.sparse <- function(
adjmatrix,
mode,
weighted = NULL,
diag = TRUE,
call = rlang::caller_env()
) {
if (!is.null(weighted)) {
if (is.logical(weighted) && weighted) {
weighted <- "weight"
}
if (!is.character(weighted)) {
cli::cli_abort("Invalid value supplied for `weighted' argument, please see docs.", call = call)
cli::cli_abort(
"Invalid value supplied for `weighted' argument, please see docs.",
call = call
)
}
}

Expand Down Expand Up @@ -463,9 +511,15 @@ graph.adjacency.sparse <- function(adjmatrix, mode, weighted = NULL, diag = TRUE
adjmatrix <- adjmatrix + Matrix::t(adjmatrix)
adjmatrix <- Matrix::tril(adjmatrix)
} else if (mode == "max") {
adjmatrix <- pmax_AB(Matrix::tril(adjmatrix), Matrix::t(Matrix::triu(adjmatrix)))
adjmatrix <- pmax_AB(
Matrix::tril(adjmatrix),
Matrix::t(Matrix::triu(adjmatrix))
)
} else if (mode == "min") {
adjmatrix <- pmin_AB(Matrix::tril(adjmatrix), Matrix::t(Matrix::triu(adjmatrix)))
adjmatrix <- pmin_AB(
Matrix::tril(adjmatrix),
Matrix::t(Matrix::triu(adjmatrix))
)
adjmatrix <- Matrix::drop0(adjmatrix)
}
el <- mysummary(adjmatrix)
Expand Down
56 changes: 41 additions & 15 deletions R/assortativity.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@
#' @inheritParams assortativity_nominal
#' @keywords internal
#' @export
assortativity.nominal <- function(graph, types, directed = TRUE, normalized = TRUE) { # nocov start
lifecycle::deprecate_soft("2.0.0", "assortativity.nominal()", "assortativity_nominal()")
assortativity_nominal(graph = graph, types = types, directed = directed, normalized = normalized)
assortativity.nominal <- function(
graph,
types,
directed = TRUE,
normalized = TRUE
) {
# nocov start
lifecycle::deprecate_soft(
"2.0.0",
"assortativity.nominal()",
"assortativity_nominal()"
)
assortativity_nominal(
graph = graph,
types = types,
directed = directed,
normalized = normalized
)
} # nocov end

#' Assortativity coefficient
Expand All @@ -23,8 +38,13 @@ assortativity.nominal <- function(graph, types, directed = TRUE, normalized = TR
#' @inheritParams assortativity_degree
#' @keywords internal
#' @export
assortativity.degree <- function(graph, directed = TRUE) { # nocov start
lifecycle::deprecate_soft("2.0.0", "assortativity.degree()", "assortativity_degree()")
assortativity.degree <- function(graph, directed = TRUE) {
# nocov start
lifecycle::deprecate_soft(
"2.0.0",
"assortativity.degree()",
"assortativity_degree()"
)
assortativity_degree(graph = graph, directed = directed)
} # nocov end

Expand All @@ -51,7 +71,6 @@ assortativity.degree <- function(graph, directed = TRUE) { # nocov start
##
## -----------------------------------------------------------------------


#' Assortativity coefficient
#'
#' The assortativity coefficient is positive if similar vertices (based on some
Expand Down Expand Up @@ -142,14 +161,16 @@ assortativity.degree <- function(graph, directed = TRUE) { # nocov start
#' # BA model, tends to be dissortative
#' assortativity_degree(sample_pa(10000, m = 4))
#' @cdocs igraph_assortativity
assortativity <- function(graph,
values,
...,
values.in = NULL,
directed = TRUE,
normalized = TRUE,
types1 = NULL,
types2 = NULL) {
assortativity <- function(
graph,
values,
...,
values.in = NULL,
directed = TRUE,
normalized = TRUE,
types1 = NULL,
types2 = NULL
) {
if (...length() > 0) {
lifecycle::deprecate_soft(
"1.6.0",
Expand Down Expand Up @@ -194,7 +215,12 @@ assortativity <- function(graph,
assortativity_impl(graph, values, values.in, directed, normalized)
}

assortativity_legacy <- function(graph, types1, types2 = NULL, directed = TRUE) {
assortativity_legacy <- function(
graph,
types1,
types2 = NULL,
directed = TRUE
) {
assortativity_impl(graph, types1, types2, directed)
}

Expand Down
5 changes: 2 additions & 3 deletions R/basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#' @inheritParams is_igraph
#' @keywords internal
#' @export
is.igraph <- function(graph) { # nocov start
is.igraph <- function(graph) {
# nocov start
lifecycle::deprecate_soft("2.0.0", "is.igraph()", "is_igraph()")
is_igraph(graph = graph)
} # nocov end
Expand All @@ -33,8 +34,6 @@ is.igraph <- function(graph) { # nocov start
#
###################################################################



#' Is this object an igraph graph?
#'
#' @param graph An R object.
Expand Down
Loading
Loading