| Title: | Reachability-Based Primitives for Graphical Causal Inference |
|---|---|
| Description: | Provides a framework for specifying and running flexible linear-time reachability-based algorithms for graphical causal inference. Rule tables are used to encode and customize the reachability algorithm to typical causal and probabilistic reasoning tasks such as finding d-connected nodes or more advanced applications. For more information, see Wienöbst, Weichwald and Henckel (2025) <doi:10.48550/arXiv.2506.15758>. |
| Authors: | Marcel Wienöbst [aut, cre, cph], Sebastian Weichwald [aut], Leonard Henckel [aut], Authors of the dependency Rust crates [ctb] (see inst/AUTHORS file for details) |
| Maintainer: | Marcel Wienöbst <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-06-08 08:15:31 UTC |
| Source: | https://github.com/mwien/cifly |
Obtain an internal representation of a CIfly graph. Advanced usage only, mostly recommended for improving performance if the same graph is used multiple times. The parsed graph object can be passed to all methods with a graph argument. It is compatible with all ruletables that have the same EDGES ... line as the ruletable passed as argument.
parseGraph(graph, ruletable, tableAsString = FALSE)parseGraph(graph, ruletable, tableAsString = FALSE)
graph |
A list mapping edge types to edge lists. |
ruletable |
Path to a ruletable file. |
tableAsString |
Optional argument to enable passing the ruletable as multi-line string. Default value is FALSE. |
Internal CIfly graph representation.
dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) g <- parseGraph(edgelist, dsepTable, tableAsString=TRUE) sets <- list("X" = c(1), "Z" = c(4)) reach(edgelist, sets, dsepTable, tableAsString=TRUE)dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) g <- parseGraph(edgelist, dsepTable, tableAsString=TRUE) sets <- list("X" = c(1), "Z" = c(4)) reach(edgelist, sets, dsepTable, tableAsString=TRUE)
Obtain an internal representation of a CIfly ruletable. Advanced usage only, mostly recommended for improving performance if the same ruletable is used multiple times. The parsed ruletable object can be passed to all methods with a ruletable argument.
parseRuletable(ruletable, tableAsString = FALSE)parseRuletable(ruletable, tableAsString = FALSE)
ruletable |
Path to a ruletable file. |
tableAsString |
Optional argument to enable passing the ruletable as multi-line string. Default value is FALSE. |
Internal CIfly ruletable representation.
dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " rt <- parseRuletable(dsepTable, tableAsString=TRUE) edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) sets <- list("X" = c(1), "Z" = c(4)) reach(edgelist, sets, rt)dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " rt <- parseRuletable(dsepTable, tableAsString=TRUE) edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) sets <- list("X" = c(1), "Z" = c(4)) reach(edgelist, sets, rt)
Obtain an internal representation of CIfly sets. Advanced usage only, mostly recommended for improving performance if the same sets are used multiple times. The parsed sets object can be passed to all methods with a sets argument. It is compatible with all ruletables that have the same SETS ... line as the ruletable passed as argument.
parseSets(sets, ruletable, tableAsString = FALSE)parseSets(sets, ruletable, tableAsString = FALSE)
sets |
A list mapping set names to a list of elements. |
ruletable |
Path to a ruletable file. |
tableAsString |
Optional argument to enable passing the ruletable as multi-line string. Default value is FALSE. |
Internal CIfly sets representation.
dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " sets <- list("X" = c(1), "Z" = c(4)) s <- parseSets(sets, dsepTable, tableAsString=TRUE) edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) reach(edgelist, s, dsepTable, tableAsString=TRUE)dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " sets <- list("X" = c(1), "Z" = c(4)) s <- parseSets(sets, dsepTable, tableAsString=TRUE) edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) reach(edgelist, s, dsepTable, tableAsString=TRUE)
For the given graph and sets, a CIfly reachability algorithm is run according to the ruletable specified in the ruletable argument. The algorithm returns all reachable nodes. It is guaranteed to run in linear-time.
reach(graph, sets, ruletable, tableAsString = FALSE, verbose = FALSE)reach(graph, sets, ruletable, tableAsString = FALSE, verbose = FALSE)
graph |
A list mapping edge types to edge lists stored in matrix format. |
sets |
A list mapping set names to a list of elements. |
ruletable |
Path to a ruletable file. |
tableAsString |
Optional argument to enable passing the ruletable as multi-line string. Default value is FALSE. |
verbose |
Optional argument to enable logging. Default value is FALSE. |
A vector of all reachable nodes.
dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) sets <- list("X" = c(1), "Z" = c(4)) reach(edgelist, sets, dsepTable, tableAsString=TRUE)dsepTable <- " EDGES --> <-- SETS X, Z START <-- AT X OUTPUT ... --> | <-- | current in Z ... | ... | current not in Z " edgelist <- list("-->" = rbind(c(1, 2), c(3, 2), c(2, 4))) sets <- list("X" = c(1), "Z" = c(4)) reach(edgelist, sets, dsepTable, tableAsString=TRUE)