Learn R Programming

caugi (version 1.1.0)

caugi_verbs: Manipulate nodes and edges of a caugi

Description

Add, remove, or and set nodes or edges to / from a caugi object. Edges can be specified using expressions with the infix operators. Alternatively, the edges to be added are specified using the from, edge, and to arguments.

Usage

add_edges(cg, ..., from = NULL, edge = NULL, to = NULL, inplace = FALSE)

remove_edges(cg, ..., from = NULL, edge = NULL, to = NULL, inplace = FALSE)

set_edges(cg, ..., from = NULL, edge = NULL, to = NULL, inplace = FALSE)

add_nodes(cg, ..., name = NULL, inplace = FALSE)

remove_nodes(cg, ..., name = NULL, inplace = FALSE)

Value

The updated caugi.

Arguments

cg

A caugi object.

...

Expressions specifying edges to add using the infix operators, or nodes to add using unquoted names, vectors via c(), or + composition.

from

Character vector of source node names. Default is NULL.

edge

Character vector of edge types. Default is NULL.

to

Character vector of target node names. Default is NULL.

inplace

DEPRECATED This parameter is deprecated and will be ignored. Graphs are always modified via copy-on-write.

name

Character vector of node names. Default is NULL.

Functions

  • add_edges(): Add edges.

  • remove_edges(): Remove edges.

  • set_edges(): Set edge type for given pair(s).

  • add_nodes(): Add nodes.

  • remove_nodes(): Remove nodes.

Details

Caugi graph verbs

See Also

Other verbs: build()

Examples

Run this code
# initialize empty graph and build slowly
cg <- caugi(class = "PDAG")

cg <- cg |>
  add_nodes(c("A", "B", "C", "D", "E")) |> # A, B, C, D, E
  add_edges(A %-->% B %-->% C) |> # A --> B --> C, D, E
  set_edges(B %---% C) # A --> B --- C, D, E

cg <- remove_edges(cg, B %---% C) |> # A --> B, C, D, E
  remove_nodes(c("C", "D", "E")) # A --> B

# Graphs are now built lazily when needed
parents(cg, "B") # triggers compilation

Run the code above in your browser using DataLab