Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion R/make.R
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,11 @@ empty_graph <- function(n = 0, directed = TRUE) {
#' all arguments are passed to `graph_from_literal()`.
#' @param simplify Logical scalar, whether to call [simplify()]
#' on the created graph. By default the graph is simplified, loop and
#' multiple edges are removed.
#' multiple edges are removed. [simplify()] is only called when the
#' created graph is not already simple, so the edge order from the
#' formula is preserved whenever no loops or multi-edges are present.
#' When the graph does contain loops or multi-edges (and `simplify =
#' TRUE`), [simplify()] reorders the edges into its canonical order.
#' @return An igraph graph
#'
#' @family deterministic constructors
Expand Down
14 changes: 12 additions & 2 deletions R/simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ is.simple <- function(graph) {
#'
#' `simplify()` removes the loop and/or multiple edges from a graph. If
#' both `remove.loops` and `remove.multiple` are `TRUE` the
#' function returns a simple graph.
#' function returns a simple graph. If the graph is already simple, it is
#' returned unchanged.
#'
#' `simplify_and_colorize()` constructs a new, simple graph from a graph and
#' also sets a `color` attribute on both the vertices and the edges.
Expand All @@ -71,7 +72,8 @@ is.simple <- function(graph) {
#' `remove.multiple=TRUE`. In this case many edges might be mapped to a
#' single one in the new graph, and their attributes are combined. Please see
#' [attribute.combination()] for details on this.
#' @return a new graph object with the edges deleted.
#' @return a graph object with the loop and/or multiple edges removed; the
#' input graph is returned unchanged if it is already simple.
#' @author Gabor Csardi \email{csardi.gabor@@gmail.com}
#' @seealso [which_loop()], [which_multiple()] and
#' [count_multiple()], [delete_edges()],
Expand All @@ -94,6 +96,14 @@ simplify <- function(
remove.loops = TRUE,
edge.attr.comb = igraph_opt("edge.attr.comb")
) {
# A graph that is already simple has no loops and no multiple edges, so
# simplify_impl() would not change its structure regardless of the
# remove.* / edge.attr.comb arguments. Short-circuiting here avoids the
# cost of rebuilding the graph in the (common) already-simple case;
# is_simple() is orders of magnitude cheaper than simplify().
if (is_simple(graph)) {
return(graph)
}
simplify_impl(
graph = graph,
remove_multiple = remove.multiple,
Expand Down
2 changes: 1 addition & 1 deletion man/alpha.centrality.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/alpha_centrality.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/as.igraph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/bonpow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/dot-apply_modifiers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/from_incidence_matrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph.adjacency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph.edgelist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph.famous.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions man/graph.formula.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading