dag <- cgraph(A %-->% B)
add_nodes(dag, "C")
#> DAG with 3 nodes and 1 edge:
#> nodes: A, B, C
#> edges:
#> A --> B
remove_nodes(dag, "B")
#> DAG with 1 node and 0 edges:
#> nodes: A
#> edges:
#> (none)

Add or remove isolated nodes
Source: R/transform.R
Description
add_nodes() returns a new graph of the same class with nodes added as isolated nodes (nodes already present are ignored). remove_nodes() returns a new graph with nodes and all their incident edges removed, and errors if a node is not present.
Usage
add_nodes(cg, nodes)
remove_nodes(cg, nodes)Arguments
cg
|
A graph created with cgraph(), of any class.
|
nodes
|
Character vector of node names. |
Value
A cgraph.