Skip to main content

Compare two graphs

Source: R/construction.R

Description

Two graphs are equal if they have the same class, the same nodes and the same edges, regardless of the order they were added in. Use markov_equivalent() to compare equivalence classes instead.

Usage

## S3 method for class 'cgraph'
e1 == e2

## S3 method for class 'cgraph'
e1 != e2

Arguments

e1, e2 Graphs created with cgraph().

Value

A logical scalar.

Examples

g1 <- cgraph(A %-->% B, B %-->% C)
g2 <- cgraph(B %-->% C, A %-->% B)
g3 <- reclass(g1, "UNKNOWN")
g1 == g2 # edges added in a different order
#> [1] TRUE
g1 == g3 # same edges, different class
#> [1] FALSE