diff --git a/.gitignore b/.gitignore index dd12d586c35..0e66fa56a88 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ cran /src/*.d /src/symbols.rds /covr +*.dd diff --git a/NAMESPACE b/NAMESPACE index 95be07fb203..120f3ad8cf1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -133,6 +133,7 @@ export(alpha.centrality) export(alpha_centrality) export(any_loop) export(any_multiple) +export(any_mutual) export(are.connected) export(are_adjacent) export(arpack) @@ -529,6 +530,7 @@ export(induced_subgraph) export(infomap.community) export(interconnected.islands.game) export(intersection) +export(invalidate_cache) export(is.bipartite) export(is.chordal) export(is.connected) @@ -648,6 +650,7 @@ export(local_scan) export(make_) export(make_bipartite_graph) export(make_chordal_ring) +export(make_circulant) export(make_clusters) export(make_de_bruijn_graph) export(make_directed_graph) @@ -657,15 +660,22 @@ export(make_from_prufer) export(make_full_bipartite_graph) export(make_full_citation_graph) export(make_full_graph) +export(make_full_multipartite) +export(make_generalized_petersen) export(make_graph) export(make_kautz_graph) export(make_lattice) export(make_line_graph) export(make_neighborhood_graph) +export(make_regular_tree) export(make_ring) export(make_star) +export(make_symmetric_tree) export(make_tree) +export(make_triangular_lattice) +export(make_turan) export(make_undirected_graph) +export(make_wheel) export(match_vertices) export(max_bipartite_match) export(max_cardinality) diff --git a/R/make.R b/R/make.R index 7547b44e593..e3d48fda71e 100644 --- a/R/make.R +++ b/R/make.R @@ -2806,3 +2806,183 @@ realize_bipartite_degseq <- function( V(g)$type <- c(rep(TRUE, length(degrees1)), rep(FALSE, length(degrees2))) g } + +#' Create a wheel graph +#' +#' A wheel graph is a graph formed by connecting a single universal vertex to +#' all vertices of a cycle. +#' +#' @param n The number of vertices in the graph. +#' @param mode Specifies the mode of the wheel graph: +#' * `"out"`: A directed graph where edges point from the center to the rim and around the rim. +#' * `"in"`: A directed graph where edges point from the rim to the center and around the rim. +#' * `"undirected"`: An undirected graph. +#' * `"mutual"`: A directed graph with mutual edges. +#' @param center The index of the center vertex, defaults to 0. +#' @return An igraph graph. +#' @family deterministic constructors +#' @export +#' @examples +#' make_wheel(10) +#' make_wheel(10, mode = "in") +#' @cdocs igraph_wheel +make_wheel <- function( + n, + mode = c("out", "in", "undirected", "mutual"), + center = 0 +) { + wheel_impl(n = n, mode = mode, center = center) +} + +#' Create a circulant graph +#' +#' A circulant graph is a graph where vertices are arranged in a circle and +#' each vertex is connected to vertices at certain distances (shifts) from it. +#' +#' @param n The number of vertices in the graph. +#' @param shifts A numeric vector specifying the shifts. Each vertex i will be +#' connected to vertex (i + shift) mod n for each shift in the vector. +#' @param directed Whether to create a directed graph. +#' @return An igraph graph. +#' @family deterministic constructors +#' @export +#' @examples +#' make_circulant(10, c(1, 3)) +#' make_circulant(10, c(1, 2, 3), directed = TRUE) +#' @cdocs igraph_circulant +make_circulant <- function(n, shifts, directed = FALSE) { + circulant_impl(n = n, shifts = shifts, directed = directed) +} + +#' Create a Turán graph +#' +#' A Turán graph is a complete multipartite graph formed by partitioning a set +#' of n vertices into r subsets, with edges between vertices in different +#' subsets but not within the same subset. +#' +#' @param n The number of vertices in the graph. +#' @param r The number of partitions. +#' @return An igraph graph with a `type` vertex attribute indicating partition membership. +#' @family deterministic constructors +#' @export +#' @examples +#' make_turan(10, 3) +#' make_turan(13, 4) +#' @cdocs igraph_turan +make_turan <- function(n, r) { + result <- turan_impl(n = n, r = r) + graph <- result$graph + V(graph)$type <- result$types + graph +} + +#' Create a generalized Petersen graph +#' +#' The generalized Petersen graph is a cubic graph formed by connecting +#' vertices of a regular polygon to a star polygon. +#' +#' @param n The number of vertices in the outer and inner polygons. +#' @param k The step size for the star polygon. +#' @return An igraph graph. +#' @family deterministic constructors +#' @export +#' @examples +#' make_generalized_petersen(5, 2) +#' make_generalized_petersen(8, 3) +#' @cdocs igraph_generalized_petersen +make_generalized_petersen <- function(n, k) { + generalized_petersen_impl(n = n, k = k) +} + +#' Create a full multipartite graph +#' +#' A full multipartite graph consists of several partitions with edges between +#' vertices in different partitions but no edges within a partition. +#' +#' @param n A numeric vector specifying the size of each partition. +#' @param directed Whether to create a directed graph. +#' @param mode For directed graphs, specifies how edges are oriented: +#' * `"all"` or `"total"`: Edges in both directions. +#' * `"out"`: Edges from lower-indexed to higher-indexed partitions. +#' * `"in"`: Edges from higher-indexed to lower-indexed partitions. +#' @return An igraph graph with a `type` vertex attribute indicating partition membership. +#' @family deterministic constructors +#' @export +#' @examples +#' make_full_multipartite(c(3, 4, 2)) +#' make_full_multipartite(c(2, 3, 4), directed = TRUE, mode = "out") +#' @cdocs igraph_full_multipartite +make_full_multipartite <- function( + n, + directed = FALSE, + mode = c("all", "out", "in", "total") +) { + result <- full_multipartite_impl(n = n, directed = directed, mode = mode) + graph <- result$graph + V(graph)$type <- result$types + graph +} + +#' Create a regular tree graph +#' +#' A regular tree is a tree where all internal vertices have the same degree. +#' +#' @param h The height of the tree (number of levels). +#' @param k The degree of internal vertices (branching factor), defaults to 3. +#' @param type Whether to create an undirected tree or a directed tree with +#' edges pointing outward (`"out"`) or inward (`"in"`). +#' @return An igraph graph. +#' @family deterministic constructors +#' @export +#' @examples +#' make_regular_tree(3, 2) +#' make_regular_tree(4, 3, type = "out") +#' @cdocs igraph_regular_tree +make_regular_tree <- function(h, k = 3, type = c("undirected", "out", "in")) { + regular_tree_impl(h = h, k = k, type = type) +} + +#' Create a symmetric tree graph +#' +#' A symmetric tree where each level has a specified branching factor. +#' +#' @param branches A numeric vector specifying the branching factor at each level. +#' @param type Whether to create an undirected tree or a directed tree with +#' edges pointing outward (`"out"`) or inward (`"in"`). +#' @return An igraph graph. +#' @family deterministic constructors +#' @export +#' @examples +#' make_symmetric_tree(c(2, 3)) +#' make_symmetric_tree(c(2, 2, 3), type = "out") +#' @cdocs igraph_symmetric_tree +make_symmetric_tree <- function(branches, type = c("out", "in", "undirected")) { + symmetric_tree_impl(branches = branches, type = type) +} + +#' Create a triangular lattice +#' +#' A triangular lattice is a two-dimensional lattice where each vertex is +#' connected to its six neighbors in a triangular pattern. +#' +#' @param dimvector A numeric vector of length 2 specifying the dimensions of the lattice. +#' @param directed Whether to create a directed lattice. +#' @param mutual Whether directed edges should be mutual (bidirectional). +#' @return An igraph graph. +#' @family deterministic constructors +#' @export +#' @examples +#' make_triangular_lattice(c(5, 5)) +#' make_triangular_lattice(c(4, 6), directed = TRUE, mutual = TRUE) +#' @cdocs igraph_triangular_lattice +make_triangular_lattice <- function( + dimvector, + directed = FALSE, + mutual = FALSE +) { + triangular_lattice_impl( + dimvector = dimvector, + directed = directed, + mutual = mutual + ) +} diff --git a/R/structural-properties.R b/R/structural-properties.R index b99ba9e37f5..78ca1be6c33 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -3478,6 +3478,37 @@ which_mutual <- function(graph, eids = E(graph), loops = TRUE) { ) } +#' Check if a graph has any mutual edges +#' +#' This function checks whether a directed graph has any mutual edges at all. +#' +#' In a directed graph an (A,B) edge is mutual if the graph also includes a +#' (B,A) directed edge. +#' +#' Undirected graphs always have mutual edges by definition. +#' +#' @param graph The input graph. +#' @param loops Logical, whether to consider directed self-loops to be mutual. +#' @return A logical scalar, `TRUE` if the graph has at least one mutual edge, +#' `FALSE` otherwise. +#' @author Gabor Csardi \email{csardi.gabor@@gmail.com} +#' @seealso [which_mutual()], [reciprocity()], [dyad_census()] +#' @keywords graphs +#' @examples +#' +#' g <- sample_gnm(10, 50, directed = TRUE) +#' any_mutual(g) +#' reciprocity(g) +#' @family structural.properties +#' @export +#' @cdocs igraph_has_mutual +any_mutual <- function(graph, loops = TRUE) { + has_mutual_impl( + graph = graph, + loops = loops + ) +} + #' Average nearest neighbor degree #' diff --git a/R/utils.R b/R/utils.R index fad1d5c10e6..4f5de96be5a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -94,3 +94,24 @@ modify_list <- function(x, y) { utils::modifyList(x, y) } + +#' Invalidate cached properties of a graph +#' +#' This function invalidates all cached properties of a graph. +#' It is primarily useful for debugging purposes. +#' +#' igraph caches some properties of graphs to improve performance. +#' This function forces igraph to recompute these properties when they are +#' next accessed. +#' +#' @param graph The input graph. +#' @return The graph with invalidated cache. +#' This function is called for its side effects and returns the modified graph. +#' @export +#' @cdocs igraph_invalidate_cache +#' @examples +#' g <- make_ring(10) +#' g <- invalidate_cache(g) +invalidate_cache <- function(graph) { + invalidate_cache_impl(graph = graph) +} diff --git a/man/any_mutual.Rd b/man/any_mutual.Rd new file mode 100644 index 00000000000..e18dfdadd20 --- /dev/null +++ b/man/any_mutual.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/structural-properties.R +\name{any_mutual} +\alias{any_mutual} +\title{Check if a graph has any mutual edges} +\usage{ +any_mutual(graph, loops = TRUE) +} +\arguments{ +\item{graph}{The input graph.} + +\item{loops}{Logical, whether to consider directed self-loops to be mutual.} +} +\value{ +A logical scalar, \code{TRUE} if the graph has at least one mutual edge, +\code{FALSE} otherwise. +} +\description{ +This function checks whether a directed graph has any mutual edges at all. +} +\details{ +In a directed graph an (A,B) edge is mutual if the graph also includes a +(B,A) directed edge. + +Undirected graphs always have mutual edges by definition. +} +\examples{ + +g <- sample_gnm(10, 50, directed = TRUE) +any_mutual(g) +reciprocity(g) +} +\seealso{ +\code{\link[=which_mutual]{which_mutual()}}, \code{\link[=reciprocity]{reciprocity()}}, \code{\link[=dyad_census]{dyad_census()}} + +Other structural.properties: +\code{\link{bfs}()}, +\code{\link{component_distribution}()}, +\code{\link{connect}()}, +\code{\link{constraint}()}, +\code{\link{coreness}()}, +\code{\link{degree}()}, +\code{\link{dfs}()}, +\code{\link{distance_table}()}, +\code{\link{edge_density}()}, +\code{\link{feedback_arc_set}()}, +\code{\link{feedback_vertex_set}()}, +\code{\link{girth}()}, +\code{\link{is_acyclic}()}, +\code{\link{is_dag}()}, +\code{\link{is_matching}()}, +\code{\link{k_shortest_paths}()}, +\code{\link{knn}()}, +\code{\link{reciprocity}()}, +\code{\link{subcomponent}()}, +\code{\link{subgraph}()}, +\code{\link{topo_sort}()}, +\code{\link{transitivity}()}, +\code{\link{unfold_tree}()}, +\code{\link{which_multiple}()}, +\code{\link{which_mutual}()} +} +\author{ +Gabor Csardi \email{csardi.gabor@gmail.com} +} +\concept{structural.properties} +\keyword{graphs} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_has_mutual}{\code{has_mutual()}}.} + diff --git a/man/bfs.Rd b/man/bfs.Rd index d72f3f76036..c2283cfb05c 100644 --- a/man/bfs.Rd +++ b/man/bfs.Rd @@ -169,6 +169,7 @@ bfs(make_ring(10) \%du\% make_ring(10), root = 1, callback = f) \code{\link[=dfs]{dfs()}} for depth-first search. Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, \code{\link{constraint}()}, diff --git a/man/components.Rd b/man/components.Rd index ac7bffb001b..c28fd2284aa 100644 --- a/man/components.Rd +++ b/man/components.Rd @@ -101,6 +101,7 @@ Connected components \code{\link{is_biconnected}()} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{connect}()}, \code{\link{constraint}()}, diff --git a/man/constraint.Rd b/man/constraint.Rd index ae337644aa5..367e248cef8 100644 --- a/man/constraint.Rd +++ b/man/constraint.Rd @@ -53,6 +53,7 @@ Burt, R.S. (2004). Structural holes and good ideas. } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/coreness.Rd b/man/coreness.Rd index c77603f3369..2e1215f716b 100644 --- a/man/coreness.Rd +++ b/man/coreness.Rd @@ -48,6 +48,7 @@ Networks}, 5, 269--287. \code{\link[=degree]{degree()}} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/degree.Rd b/man/degree.Rd index 098cf73fea2..e9e48774204 100644 --- a/man/degree.Rd +++ b/man/degree.Rd @@ -71,6 +71,7 @@ degree_distribution(g2) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/dfs.Rd b/man/dfs.Rd index 643c7031f03..516f2b19a1d 100644 --- a/man/dfs.Rd +++ b/man/dfs.Rd @@ -160,6 +160,7 @@ tmp <- dfs( \code{\link[=bfs]{bfs()}} for breadth-first search. Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/distances.Rd b/man/distances.Rd index 96ffa1c2860..17fb99b10bc 100644 --- a/man/distances.Rd +++ b/man/distances.Rd @@ -290,6 +290,7 @@ Saddle River, N.J.: Prentice Hall. } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/edge_density.Rd b/man/edge_density.Rd index 99b4db0eb71..78557917b19 100644 --- a/man/edge_density.Rd +++ b/man/edge_density.Rd @@ -50,6 +50,7 @@ Methods and Applications. Cambridge: Cambridge University Press. to get rid of the multiple and/or loop edges. Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/ego.Rd b/man/ego.Rd index 69c018240fe..67ad5e614af 100644 --- a/man/ego.Rd +++ b/man/ego.Rd @@ -176,6 +176,7 @@ Other functions for manipulating graph structure: \code{\link{vertex}()} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{constraint}()}, diff --git a/man/feedback_arc_set.Rd b/man/feedback_arc_set.Rd index 59a41641f6a..8e3ecc0932b 100644 --- a/man/feedback_arc_set.Rd +++ b/man/feedback_arc_set.Rd @@ -51,6 +51,7 @@ heuristic for the feedback arc set problem. \emph{Information Processing Letters } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/feedback_vertex_set.Rd b/man/feedback_vertex_set.Rd index 06f635f7ee5..0f4bfa87450 100644 --- a/man/feedback_vertex_set.Rd +++ b/man/feedback_vertex_set.Rd @@ -37,6 +37,7 @@ feedback_vertex_set(g) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/girth.Rd b/man/girth.Rd index c95e85f018b..edbe8258616 100644 --- a/man/girth.Rd +++ b/man/girth.Rd @@ -58,6 +58,7 @@ computing}, 1-10, 1977 } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/graph_from_atlas.Rd b/man/graph_from_atlas.Rd index f54d1fc6466..8333523cf25 100644 --- a/man/graph_from_atlas.Rd +++ b/man/graph_from_atlas.Rd @@ -44,14 +44,22 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Graph Atlas.} \concept{deterministic constructors} diff --git a/man/graph_from_edgelist.Rd b/man/graph_from_edgelist.Rd index 453451315d3..a8599acd2d5 100644 --- a/man/graph_from_edgelist.Rd +++ b/man/graph_from_edgelist.Rd @@ -40,14 +40,22 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Edge list} \concept{deterministic constructors} diff --git a/man/graph_from_literal.Rd b/man/graph_from_literal.Rd index 191735aed37..036f34ac0e0 100644 --- a/man/graph_from_literal.Rd +++ b/man/graph_from_literal.Rd @@ -131,13 +131,21 @@ Other deterministic constructors: \code{\link{graph_from_edgelist}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{deterministic constructors} diff --git a/man/invalidate_cache.Rd b/man/invalidate_cache.Rd new file mode 100644 index 00000000000..6c0d468d693 --- /dev/null +++ b/man/invalidate_cache.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{invalidate_cache} +\alias{invalidate_cache} +\title{Invalidate cached properties of a graph} +\usage{ +invalidate_cache(graph) +} +\arguments{ +\item{graph}{The input graph.} +} +\value{ +The graph with invalidated cache. +This function is called for its side effects and returns the modified graph. +} +\description{ +This function invalidates all cached properties of a graph. +It is primarily useful for debugging purposes. +} +\details{ +igraph caches some properties of graphs to improve performance. +This function forces igraph to recompute these properties when they are +next accessed. +} +\examples{ +g <- make_ring(10) +g <- invalidate_cache(g) +} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Basic.html#igraph_invalidate_cache}{\code{invalidate_cache()}}.} + diff --git a/man/is_acyclic.Rd b/man/is_acyclic.Rd index 21a8b7dc86d..99e4b43d8f1 100644 --- a/man/is_acyclic.Rd +++ b/man/is_acyclic.Rd @@ -39,6 +39,7 @@ Graph cycles \code{\link{simple_cycles}()} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/is_dag.Rd b/man/is_dag.Rd index 0c651de7b3e..93a54768ff5 100644 --- a/man/is_dag.Rd +++ b/man/is_dag.Rd @@ -39,6 +39,7 @@ Graph cycles \code{\link{simple_cycles}()} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/k_shortest_paths.Rd b/man/k_shortest_paths.Rd index c136dc00977..360429e5f28 100644 --- a/man/k_shortest_paths.Rd +++ b/man/k_shortest_paths.Rd @@ -66,6 +66,7 @@ Quarterly of Applied Mathematics. 27 (4): 526–530. (1970) \code{\link[=shortest_paths]{shortest_paths()}}, \code{\link[=all_shortest_paths]{all_shortest_paths()}} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/knn.Rd b/man/knn.Rd index 13c35422f0c..8e89136b733 100644 --- a/man/knn.Rd +++ b/man/knn.Rd @@ -95,6 +95,7 @@ Natl. Acad. Sci. USA 101, 3747 (2004) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/make_.Rd b/man/make_.Rd index 1d988b9d4ac..6f03885b854 100644 --- a/man/make_.Rd +++ b/man/make_.Rd @@ -47,14 +47,22 @@ Other deterministic constructors: \code{\link{graph_from_edgelist}()}, \code{\link{graph_from_literal}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} Constructor modifiers (and related functions) \code{\link{sample_}()}, diff --git a/man/make_chordal_ring.Rd b/man/make_chordal_ring.Rd index 2b4127f4d01..034c833e611 100644 --- a/man/make_chordal_ring.Rd +++ b/man/make_chordal_ring.Rd @@ -47,13 +47,21 @@ Other deterministic constructors: \code{\link{graph_from_edgelist}()}, \code{\link{graph_from_literal}()}, \code{\link{make_}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{deterministic constructors} diff --git a/man/make_circulant.Rd b/man/make_circulant.Rd new file mode 100644 index 00000000000..73f11cdc6e8 --- /dev/null +++ b/man/make_circulant.Rd @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_circulant} +\alias{make_circulant} +\title{Create a circulant graph} +\usage{ +make_circulant(n, shifts, directed = FALSE) +} +\arguments{ +\item{n}{The number of vertices in the graph.} + +\item{shifts}{A numeric vector specifying the shifts. Each vertex i will be +connected to vertex (i + shift) mod n for each shift in the vector.} + +\item{directed}{Whether to create a directed graph.} +} +\value{ +An igraph graph. +} +\description{ +A circulant graph is a graph where vertices are arranged in a circle and +each vertex is connected to vertices at certain distances (shifts) from it. +} +\examples{ +make_circulant(10, c(1, 3)) +make_circulant(10, c(1, 2, 3), directed = TRUE) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_circulant}{\code{circulant()}}.} + diff --git a/man/make_empty_graph.Rd b/man/make_empty_graph.Rd index 030f1ed1b97..3bac3ea6a90 100644 --- a/man/make_empty_graph.Rd +++ b/man/make_empty_graph.Rd @@ -33,13 +33,21 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Empty graph.} \concept{deterministic constructors} diff --git a/man/make_full_citation_graph.Rd b/man/make_full_citation_graph.Rd index 1b71a67b0ee..d46a21eee1e 100644 --- a/man/make_full_citation_graph.Rd +++ b/man/make_full_citation_graph.Rd @@ -34,12 +34,20 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{deterministic constructors} diff --git a/man/make_full_graph.Rd b/man/make_full_graph.Rd index be28e7efc5b..8e92e66583d 100644 --- a/man/make_full_graph.Rd +++ b/man/make_full_graph.Rd @@ -35,13 +35,21 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Full graph} \concept{deterministic constructors} diff --git a/man/make_full_multipartite.Rd b/man/make_full_multipartite.Rd new file mode 100644 index 00000000000..fb364000087 --- /dev/null +++ b/man/make_full_multipartite.Rd @@ -0,0 +1,61 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_full_multipartite} +\alias{make_full_multipartite} +\title{Create a full multipartite graph} +\usage{ +make_full_multipartite( + n, + directed = FALSE, + mode = c("all", "out", "in", "total") +) +} +\arguments{ +\item{n}{A numeric vector specifying the size of each partition.} + +\item{directed}{Whether to create a directed graph.} + +\item{mode}{For directed graphs, specifies how edges are oriented: +\itemize{ +\item \code{"all"} or \code{"total"}: Edges in both directions. +\item \code{"out"}: Edges from lower-indexed to higher-indexed partitions. +\item \code{"in"}: Edges from higher-indexed to lower-indexed partitions. +}} +} +\value{ +An igraph graph with a \code{type} vertex attribute indicating partition membership. +} +\description{ +A full multipartite graph consists of several partitions with edges between +vertices in different partitions but no edges within a partition. +} +\examples{ +make_full_multipartite(c(3, 4, 2)) +make_full_multipartite(c(2, 3, 4), directed = TRUE, mode = "out") +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_full_multipartite}{\code{full_multipartite()}}.} + diff --git a/man/make_generalized_petersen.Rd b/man/make_generalized_petersen.Rd new file mode 100644 index 00000000000..7ccfdf8dc7e --- /dev/null +++ b/man/make_generalized_petersen.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_generalized_petersen} +\alias{make_generalized_petersen} +\title{Create a generalized Petersen graph} +\usage{ +make_generalized_petersen(n, k) +} +\arguments{ +\item{n}{The number of vertices in the outer and inner polygons.} + +\item{k}{The step size for the star polygon.} +} +\value{ +An igraph graph. +} +\description{ +The generalized Petersen graph is a cubic graph formed by connecting +vertices of a regular polygon to a star polygon. +} +\examples{ +make_generalized_petersen(5, 2) +make_generalized_petersen(8, 3) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_generalized_petersen}{\code{generalized_petersen()}}.} + diff --git a/man/make_graph.Rd b/man/make_graph.Rd index 96d8bf78c0d..49eaed62509 100644 --- a/man/make_graph.Rd +++ b/man/make_graph.Rd @@ -244,12 +244,20 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{deterministic constructors} diff --git a/man/make_lattice.Rd b/man/make_lattice.Rd index 52e2dfe39cb..7e755b28ffb 100644 --- a/man/make_lattice.Rd +++ b/man/make_lattice.Rd @@ -64,13 +64,21 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Lattice} \concept{deterministic constructors} diff --git a/man/make_regular_tree.Rd b/man/make_regular_tree.Rd new file mode 100644 index 00000000000..1addc005753 --- /dev/null +++ b/man/make_regular_tree.Rd @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_regular_tree} +\alias{make_regular_tree} +\title{Create a regular tree graph} +\usage{ +make_regular_tree(h, k = 3, type = c("undirected", "out", "in")) +} +\arguments{ +\item{h}{The height of the tree (number of levels).} + +\item{k}{The degree of internal vertices (branching factor), defaults to 3.} + +\item{type}{Whether to create an undirected tree or a directed tree with +edges pointing outward (\code{"out"}) or inward (\code{"in"}).} +} +\value{ +An igraph graph. +} +\description{ +A regular tree is a tree where all internal vertices have the same degree. +} +\examples{ +make_regular_tree(3, 2) +make_regular_tree(4, 3, type = "out") +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_regular_tree}{\code{regular_tree()}}.} + diff --git a/man/make_ring.Rd b/man/make_ring.Rd index 25cadf9e45a..e889a08613d 100644 --- a/man/make_ring.Rd +++ b/man/make_ring.Rd @@ -41,12 +41,20 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{deterministic constructors} diff --git a/man/make_star.Rd b/man/make_star.Rd index 59dd345bedb..490a177b0e8 100644 --- a/man/make_star.Rd +++ b/man/make_star.Rd @@ -40,13 +40,21 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, -\code{\link{make_tree}()} +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Star graph} \concept{deterministic constructors} diff --git a/man/make_symmetric_tree.Rd b/man/make_symmetric_tree.Rd new file mode 100644 index 00000000000..80aed47add7 --- /dev/null +++ b/man/make_symmetric_tree.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_symmetric_tree} +\alias{make_symmetric_tree} +\title{Create a symmetric tree graph} +\usage{ +make_symmetric_tree(branches, type = c("out", "in", "undirected")) +} +\arguments{ +\item{branches}{A numeric vector specifying the branching factor at each level.} + +\item{type}{Whether to create an undirected tree or a directed tree with +edges pointing outward (\code{"out"}) or inward (\code{"in"}).} +} +\value{ +An igraph graph. +} +\description{ +A symmetric tree where each level has a specified branching factor. +} +\examples{ +make_symmetric_tree(c(2, 3)) +make_symmetric_tree(c(2, 2, 3), type = "out") +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_symmetric_tree}{\code{symmetric_tree()}}.} + diff --git a/man/make_tree.Rd b/man/make_tree.Rd index 42446786e14..468e9b943f5 100644 --- a/man/make_tree.Rd +++ b/man/make_tree.Rd @@ -41,13 +41,21 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, \code{\link{make_ring}()}, -\code{\link{make_star}()} +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} } \concept{Trees.} \concept{deterministic constructors} diff --git a/man/make_triangular_lattice.Rd b/man/make_triangular_lattice.Rd new file mode 100644 index 00000000000..abe20d22e2f --- /dev/null +++ b/man/make_triangular_lattice.Rd @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_triangular_lattice} +\alias{make_triangular_lattice} +\title{Create a triangular lattice} +\usage{ +make_triangular_lattice(dimvector, directed = FALSE, mutual = FALSE) +} +\arguments{ +\item{dimvector}{A numeric vector of length 2 specifying the dimensions of the lattice.} + +\item{directed}{Whether to create a directed lattice.} + +\item{mutual}{Whether directed edges should be mutual (bidirectional).} +} +\value{ +An igraph graph. +} +\description{ +A triangular lattice is a two-dimensional lattice where each vertex is +connected to its six neighbors in a triangular pattern. +} +\examples{ +make_triangular_lattice(c(5, 5)) +make_triangular_lattice(c(4, 6), directed = TRUE, mutual = TRUE) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_turan}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_triangular_lattice}{\code{triangular_lattice()}}.} + diff --git a/man/make_turan.Rd b/man/make_turan.Rd new file mode 100644 index 00000000000..9f57838d9fc --- /dev/null +++ b/man/make_turan.Rd @@ -0,0 +1,51 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_turan} +\alias{make_turan} +\title{Create a Turán graph} +\usage{ +make_turan(n, r) +} +\arguments{ +\item{n}{The number of vertices in the graph.} + +\item{r}{The number of partitions.} +} +\value{ +An igraph graph with a \code{type} vertex attribute indicating partition membership. +} +\description{ +A Turán graph is a complete multipartite graph formed by partitioning a set +of n vertices into r subsets, with edges between vertices in different +subsets but not within the same subset. +} +\examples{ +make_turan(10, 3) +make_turan(13, 4) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_wheel}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_turan}{\code{turan()}}.} + diff --git a/man/make_wheel.Rd b/man/make_wheel.Rd new file mode 100644 index 00000000000..3ca0f71daed --- /dev/null +++ b/man/make_wheel.Rd @@ -0,0 +1,58 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_wheel} +\alias{make_wheel} +\title{Create a wheel graph} +\usage{ +make_wheel(n, mode = c("out", "in", "undirected", "mutual"), center = 0) +} +\arguments{ +\item{n}{The number of vertices in the graph.} + +\item{mode}{Specifies the mode of the wheel graph: +\itemize{ +\item \code{"out"}: A directed graph where edges point from the center to the rim and around the rim. +\item \code{"in"}: A directed graph where edges point from the rim to the center and around the rim. +\item \code{"undirected"}: An undirected graph. +\item \code{"mutual"}: A directed graph with mutual edges. +}} + +\item{center}{The index of the center vertex, defaults to 0.} +} +\value{ +An igraph graph. +} +\description{ +A wheel graph is a graph formed by connecting a single universal vertex to +all vertices of a cycle. +} +\examples{ +make_wheel(10) +make_wheel(10, mode = "in") +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_generalized_petersen}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_regular_tree}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_symmetric_tree}()}, +\code{\link{make_tree}()}, +\code{\link{make_triangular_lattice}()}, +\code{\link{make_turan}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_wheel}{\code{wheel()}}.} + diff --git a/man/matching.Rd b/man/matching.Rd index aef4e2ac57a..972bb7181d6 100644 --- a/man/matching.Rd +++ b/man/matching.Rd @@ -118,6 +118,7 @@ max_bipartite_match(g2) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/reciprocity.Rd b/man/reciprocity.Rd index 72b71313216..3afb8890b0a 100644 --- a/man/reciprocity.Rd +++ b/man/reciprocity.Rd @@ -43,6 +43,7 @@ reciprocity(g) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/subcomponent.Rd b/man/subcomponent.Rd index 128a85e74b6..0176a8510fe 100644 --- a/man/subcomponent.Rd +++ b/man/subcomponent.Rd @@ -39,6 +39,7 @@ subcomponent(g, 1, "all") \code{\link[=components]{components()}} Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/subgraph.Rd b/man/subgraph.Rd index 36705561d56..e50dd1e1377 100644 --- a/man/subgraph.Rd +++ b/man/subgraph.Rd @@ -66,6 +66,7 @@ g3 <- subgraph_from_edges(g, 1:5) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/topo_sort.Rd b/man/topo_sort.Rd index 4d6cfb66c5a..06fda8a5c2f 100644 --- a/man/topo_sort.Rd +++ b/man/topo_sort.Rd @@ -38,6 +38,7 @@ topo_sort(g) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/transitivity.Rd b/man/transitivity.Rd index 2c6800eda4b..c08fefaf591 100644 --- a/man/transitivity.Rd +++ b/man/transitivity.Rd @@ -135,6 +135,7 @@ Sci. USA 101, 3747 (2004) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/unfold_tree.Rd b/man/unfold_tree.Rd index 88fef56131b..e2555ab7372 100644 --- a/man/unfold_tree.Rd +++ b/man/unfold_tree.Rd @@ -50,6 +50,7 @@ tree <- unfold_tree(g, roots = roots) } \seealso{ Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/which_multiple.Rd b/man/which_multiple.Rd index c7ae8a79065..092096f2ac7 100644 --- a/man/which_multiple.Rd +++ b/man/which_multiple.Rd @@ -86,6 +86,7 @@ E(g)$weight \code{\link[=simplify]{simplify()}} to eliminate loop and multiple edges. Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/man/which_mutual.Rd b/man/which_mutual.Rd index 9acbed38d8d..7bcd1a95121 100644 --- a/man/which_mutual.Rd +++ b/man/which_mutual.Rd @@ -43,6 +43,7 @@ sum(which_mutual(g)) / 2 == dyad_census(g)$mut want some statistics about mutual edges. Other structural.properties: +\code{\link{any_mutual}()}, \code{\link{bfs}()}, \code{\link{component_distribution}()}, \code{\link{connect}()}, diff --git a/src/cpp11.dd b/src/cpp11.dd deleted file mode 100644 index 9abbae1fcad..00000000000 --- a/src/cpp11.dd +++ /dev/null @@ -1,4 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -cpp11.o: \ - cpp11.cpp \ - igraph_types.hpp \ diff --git a/src/cpprinterface.dd b/src/cpprinterface.dd deleted file mode 100644 index b919122a665..00000000000 --- a/src/cpprinterface.dd +++ /dev/null @@ -1,4 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -cpprinterface.o: \ - cpprinterface.cpp \ - igraph_vector.hpp \ diff --git a/src/init.dd b/src/init.dd deleted file mode 100644 index d13367a3b5c..00000000000 --- a/src/init.dd +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -init.o: \ - init.cpp \ diff --git a/src/rinterface.dd b/src/rinterface.dd deleted file mode 100644 index 4e60bfc2463..00000000000 --- a/src/rinterface.dd +++ /dev/null @@ -1,4 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -rinterface.o: \ - rinterface.c \ - rinterface.h \ diff --git a/src/rinterface_extra.dd b/src/rinterface_extra.dd deleted file mode 100644 index 8abe00ad47b..00000000000 --- a/src/rinterface_extra.dd +++ /dev/null @@ -1,5 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -rinterface_extra.o: \ - rinterface.h \ - rinterface_extra.c \ - rrandom.h \ diff --git a/src/rrandom.dd b/src/rrandom.dd deleted file mode 100644 index f7531c7896f..00000000000 --- a/src/rrandom.dd +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -rrandom.o: \ - rrandom.c \ diff --git a/src/simpleraytracer.dd b/src/simpleraytracer.dd deleted file mode 100644 index 70dce28800b..00000000000 --- a/src/simpleraytracer.dd +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -simpleraytracer.o: \ - simpleraytracer.cpp \ diff --git a/src/uuid.dd b/src/uuid.dd deleted file mode 100644 index 272f3e70166..00000000000 --- a/src/uuid.dd +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers -uuid.o: \ - uuid.c \ diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index 396bf65dc43..e4e538fd94a 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -456,3 +456,80 @@ test_that("graph_from_lcf() works", { g2 <- make_graph("Franklin") expect_isomorphic(g1, g2) }) + +test_that("make_wheel works", { + g <- make_wheel(10) + expect_equal(vcount(g), 10) + expect_equal(ecount(g), 18) # 9 edges on rim + 9 spokes + + # Directed version + g_dir <- make_wheel(10, mode = "out") + expect_true(is_directed(g_dir)) + expect_equal(vcount(g_dir), 10) +}) + +test_that("make_circulant works", { + g <- make_circulant(10, c(1, 3)) + expect_equal(vcount(g), 10) + expect_equal(ecount(g), 20) # Each vertex connects to 2 others in each direction + + g_dir <- make_circulant(10, c(1, 2), directed = TRUE) + expect_true(is_directed(g_dir)) + expect_equal(vcount(g_dir), 10) +}) + +test_that("make_turan works", { + g <- make_turan(10, 3) + expect_equal(vcount(g), 10) + expect_true(is_simple(g)) + + g2 <- make_turan(13, 4) + expect_equal(vcount(g2), 13) +}) + +test_that("make_generalized_petersen works", { + g <- make_generalized_petersen(5, 2) + expect_equal(vcount(g), 10) # 2n vertices + expect_equal(ecount(g), 15) # 3n edges + + g2 <- make_generalized_petersen(8, 3) + expect_equal(vcount(g2), 16) +}) + +test_that("make_full_multipartite works", { + g <- make_full_multipartite(c(3, 4, 2)) + expect_equal(vcount(g), 9) + # 3*4 + 3*2 + 4*2 = 12 + 6 + 8 = 26 edges + expect_equal(ecount(g), 26) + + g_dir <- make_full_multipartite(c(2, 3), directed = TRUE, mode = "out") + expect_true(is_directed(g_dir)) +}) + +test_that("make_regular_tree works", { + g <- make_regular_tree(3, 2) + expect_true(is_tree(g)) + expect_equal(vcount(g), 2^3 - 1) # Binary tree with height 3 + + g2 <- make_regular_tree(4, 3, type = "out") + expect_true(is_directed(g2)) + expect_true(is_dag(g2)) +}) + +test_that("make_symmetric_tree works", { + g <- make_symmetric_tree(c(2, 3)) + expect_true(is_tree(g)) + expect_equal(vcount(g), 1 + 2 + 2 * 3) # root + 2 children + 2*3 grandchildren + + g2 <- make_symmetric_tree(c(2, 2, 3), type = "out") + expect_true(is_directed(g2)) +}) + +test_that("make_triangular_lattice works", { + g <- make_triangular_lattice(c(5, 5)) + expect_equal(vcount(g), 25) + expect_true(vcount(g) > 0) + + g_dir <- make_triangular_lattice(c(4, 6), directed = TRUE, mutual = TRUE) + expect_true(is_directed(g_dir)) +}) diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index f938d495dd0..79b4cc78c44 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -996,3 +996,31 @@ test_that("feedback_vertex_set works with weights", { fvs <- feedback_vertex_set(g) expect_equal(as.vector(fvs), c(5)) }) + +test_that("any_mutual works", { + # Directed graph with mutual edges + g1 <- make_graph(c(1, 2, 2, 1, 2, 3), directed = TRUE) + expect_true(any_mutual(g1)) + + # Directed graph without mutual edges + g2 <- make_graph(c(1, 2, 2, 3, 3, 4), directed = TRUE) + expect_false(any_mutual(g2)) + + # Undirected graph always has mutual edges + g3 <- make_graph(c(1, 2, 2, 3), directed = FALSE) + expect_true(any_mutual(g3)) + + # Graph with self-loop + g4 <- make_graph(c(1, 1, 1, 2), directed = TRUE) + expect_true(any_mutual(g4, loops = TRUE)) + expect_false(any_mutual(g4, loops = FALSE)) +}) + +test_that("invalidate_cache works", { + g <- make_ring(10) + # Should return the graph (side effect function) + g2 <- invalidate_cache(g) + expect_true(is_igraph(g2)) + expect_equal(vcount(g), vcount(g2)) + expect_equal(ecount(g), ecount(g2)) +}) diff --git a/tests/testthat/testthat-problems.rds b/tests/testthat/testthat-problems.rds deleted file mode 100644 index 95cf1759297..00000000000 Binary files a/tests/testthat/testthat-problems.rds and /dev/null differ diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index f88aaa9f1aa..fd1a01a9112 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -119,6 +119,25 @@ igraph_realize_bipartite_degree_sequence: name: Bipartite graph from degree sequence GATTR-PARAM: degrees1, degrees2, allowed_edge_types, method +igraph_wheel: + +igraph_circulant: + +igraph_turan: + +igraph_generalized_petersen: + +igraph_regular_tree: + +igraph_symmetric_tree: + +igraph_full_multipartite: + +igraph_triangular_lattice: + +# hexagonal_lattice is not yet in the cigraph interfaces/functions.yaml +# igraph_hexagonal_lattice: + # TODO: temporarily disabled igraph_weighted_sparsemat: IGNORE: RR, RC