Check properties of graphs.
Check if a graph is 1) a directed acyclic graph (DAG), 2) a directed graph (DG), 3) an undirected graph (UG), 4) a triangulated (chordal) undirected graph (TUG).
is_dag(object) is_dagMAT(object) is_ug(object) is_ugMAT(object) is_tug(object) is_tugMAT(object) is_dg(object) is_dgMAT(object) is_adjMAT(object) is.adjMAT(object)
object |
A graph represented as a 'graphNEL' (graph package), an 'igraph' (igraph package), an adjacency matrix or a sparse adjacency matrix (a 'dgCMatrix' from the Matrix package). |
* A non-zero value at entry (i,j) in an adjacency matrix A for a
graph means that there is an edge from i to j. If also (j,i) is
non-zero there is also an edge from j to i. In this case we may
think of a bidirected edge between i and j or we may think of the
edge as being undirected. We do not distinguish between undirected
and bidirected edges in the gRbase package. On the other hand,
graphNEL objects from the graph package makes such a distinction
(the function edgemode()
will tell if edges are "directed"
or "undirected" in a graphNEL object).
* The function is_ug()
checks if the adjacency matrix is
symmetric (If applied to a graphNEL, the adjacency matrix is
created and checked for symmetry.)
* The function is_tug()
checks if the graph is undirected and
triangulated (also called chordal) by checking if the adjacency matrix is
symmetric and the vertices can be given a perfect ordering using maximum
cardinality seach.
* The function is_dg()
checks if a graph is directed, i.e., that there
are no undirected edges. This is done by computing the elementwise product
of A and the transpose of A; if there are no non–zero entries in this
product then the graph is directed.
* The function is_dag()
will return TRUE
if all edges are
directed and if there are no cycles in the graph. (This is checked by
checking if the vertices in the graph can be given a topological ordering
which is based on identifying an undirected edge with a bidrected edge).
* There is a special case, namely if the graph has no edges at all (such that the adjacency matrix consists only of zeros). Such a graph is both undirected, triangulated, directed and directed acyclic.
The functions
* 'is.TUG'/'is.DAG'/'is.DG'/'is.UG'/'is.adjMAT'
are synonymous with
* 'is_tug'/'is_dag'/'is_dg'/'is_ug'/'is_adjMAT'.
The 'is.X' group of functions will be deprecated.
Søren Højsgaard, sorenh@math.aau.dk
## DAGs dagNEL <- dag(~ a:b:c + c:d:e, result="graphNEL") ## Undirected graphs ugNEL <- ug(~a:b:c + c:d:e, result="graphNEL") ## Is graph a DAG? is_dag(dagNEL) is_dag(ugNEL) ## Is graph an undirected graph is_ug(dagNEL) is_ug(ugNEL) ## Is graph a triangulated (i.e. chordal) undirected graph is_tug(dagNEL) is_tug(ugNEL) ## Example where the graph is not triangulated ug2NEL <- ug(~ a:b + b:c + c:d + d:a, result="graphNEL") is_tug(ug2NEL) ## Bidirected graphs graph::edgemode(ugNEL) graph::edgemode(ugNEL) <- "directed" graph::edgemode(ugNEL) is_dag(ugNEL) is_ug(ugNEL)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.