Skip to main content

Induced subgraph

Source: R/transform.R

Description

Returns the graph on nodes with every edge of cg between them. Errors if a node is not in cg.

Usage

subgraph(cg, nodes)

Arguments

cg A graph created with cgraph(), of any class.
nodes Character vector of node names to keep.

Value

A cgraph.

Examples

dag <- cgraph(A %-->% B, B %-->% C)
subgraph(dag, c("A", "B"))
#> DAG with 2 nodes and 1 edge:
#>   nodes: A, B
#>   edges:
#>     A --> B