Skip to contents

gs_set_edges() and gs_set_edges<- replace all edges of a GraphSpace object. The nodes, coordinates, normalization, image and geometries are not affected.

Usage

# S4 method for class 'GraphSpaceInterface'
gs_set_edges(x, value, directed = NULL, simplify = NULL, ...)

# S4 method for class 'GraphSpaceInterface'
gs_set_edges(x, directed = NULL, simplify = NULL, ...) <- value

Arguments

x

A GraphSpace object.

value

Edges that replace the current ones, in any form accepted by gs_add_edges; NULL removes all edges.

directed

A single logical value setting whether the graph is directed. If NULL (default), the graph keeps its current type.

simplify

A single logical value setting whether the graph is simplified, i.e. without loops or parallel edges. If NULL (default), the graph keeps its current setting.

...

Additional arguments (currently unused).

Value

A GraphSpace object with the new edges.

Details

In a directed graph, the edges A -> B and B -> A are distinct; in an undirected graph, they are parallel edges. In simplified objects, loops and parallel edges are dropped with a warning; use simplify = FALSE to keep them.

Examples

library(RGraphSpace)
data(gtoy1, package = "RGraphSpace")
gs <- GraphSpace(gtoy1)
#> Validating the 'igraph' object...
#> Ignoring graph-level attributes: 'name', 'mode', 'center'
#> Creating a 'GraphSpace' object...

# Replace all edges, as a directed graph
gs <- gs_set_edges(gs, data.frame(from = c("n1", "n2"), 
  to = c("n2", "n1")), directed = TRUE)

# Remove all edges
gs_set_edges(gs) <- NULL