Skip to main content

Test whether two nodes are adjacent

Source: R/construction.R, R/jlbind-wrappers.R

Description

Tests adjacency, not directed reachability: has_edge(g, x, y) and has_edge(g, y, x) always agree, even for a directed edge x --> y.

Usage

has_edge(cg, x, y)

Arguments

cg A graph created with cgraph(), of any class.
x, y Node names.

Value

TRUE if the graph has any edge between x and y, regardless of direction.

Examples

dag <- cgraph(A %-->% B, C)
has_edge(dag, "A", "B")
#> [1] TRUE
has_edge(dag, "B", "A")
#> [1] TRUE
has_edge(dag, "A", "C")
#> [1] FALSE