View source: R/queries.R View source: R/extendr-wrappers.R
| districts | R Documentation |
Get districts (c-components) for all nodes, or for selected
nodes in an ADMG/AG. A district is a maximal set of nodes connected via
bidirected edges. If both nodes and index are NULL, returns all districts in the graph.
districts(cg, nodes = NULL, index = NULL, all = NULL)
cg |
A |
nodes |
Optional character vector of node names. If supplied, returns district(s) containing these nodes. |
index |
Optional numeric vector of 1-based node indices. If supplied, returns district(s) containing these indices. |
all |
DEPRECATED (If |
If all districts are requested: a list of character vectors, one per
district. If nodes/index are supplied: either a character vector (single
target) or a named list of character vectors (multiple targets).
Other queries:
ancestors(),
anteriors(),
children(),
components(),
descendants(),
edge_types(),
edges(),
exogenous(),
is_acyclic(),
is_admg(),
is_ag(),
is_caugi(),
is_cpdag(),
is_dag(),
is_empty_caugi(),
is_mag(),
is_mpdag(),
is_pdag(),
is_simple(),
is_ug(),
m_separated(),
markov_blanket(),
neighbors(),
nodes(),
parents(),
posteriors(),
same_nodes(),
spouses(),
subgraph(),
topological_sort()
cg <- caugi(
A %-->% B,
A %<->% C,
D %<->% E,
class = "ADMG"
)
districts(cg)
# Returns list with districts: {A, C}, {B}, {D, E}
districts(cg, nodes = "A") # Returns c("A", "C")
districts(cg, index = c(1, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.