![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
Enumerations | |
| enum class | FastGraphOp : std::uint8_t { None , Arc , RevArc , Edge } |
| which operator (if any) precedes a node token in a fastGraph chain More... | |
Functions | |
| std::size_t | fastGraphFindDash (std::string_view chain, std::size_t from) |
Finds the first '-' at bracket-depth 0, starting at from, skipping any '['...']' or '{'...'}' span. | |
| std::vector< std::pair< std::string, FastGraphOp > > | fastGraphTokenize (std::string_view chain) |
| Scans one ";"-delimited chain, splitting it into node tokens while remembering, for each token, whether it was preceded by "->" (Arc), "<-" (RevArc) or "-" (Edge). | |
| bool | fastGraphIsNodeIdToken (const std::string &token) |
| true if token must be read as a NodeId (non-negative integer) | |
| template<typename GRAPH_TYPE> | |
| NodeId | fastGraphBuildNode (GRAPH_TYPE &g, const std::string &token, bool useIds) |
| gets or creates the node denoted by token, in NodeId or name mode | |
| template<typename Resolve, typename AddArc, typename AddEdge> | |
| void | fastGraphWalkTokens (const std::vector< std::pair< std::string, FastGraphOp > > &tokens, std::string_view desc, Resolve resolve, AddArc addArc, AddEdge addEdge) |
Walks one already-tokenized chain (see fastGraphTokenize()), resolving each token to a NodeId via resolve and wiring consecutive nodes via addArc / addEdge according to the operator preceding each token. | |
|
strong |
which operator (if any) precedes a node token in a fastGraph chain
| Enumerator | |
|---|---|
| None | |
| Arc | |
| RevArc | |
| Edge | |
Definition at line 58 of file fastGraph_tpl.h.
| NodeId gum::detail::fastGraphBuildNode | ( | GRAPH_TYPE & | g, |
| const std::string & | token, | ||
| bool | useIds ) |
gets or creates the node denoted by token, in NodeId or name mode
Definition at line 138 of file fastGraph_tpl.h.
References gum::isIntegerWithResult().
|
inline |
Finds the first '-' at bracket-depth 0, starting at from, skipping any '['...']' or '{'...'}' span.
Node tokens built downstream by BayesNet/InfluenceDiagram's fastPrototype() may embed a fastVariable domain descriptor, e.g. "A[-3,3]" (negative range) or "B{-1.5:6.3:5}" (negative ticks): the '-' there is part of a number, not a topology operator, so it must not be mistaken for one.
Definition at line 69 of file fastGraph_tpl.h.
Referenced by fastGraphTokenize().
|
inline |
true if token must be read as a NodeId (non-negative integer)
Definition at line 131 of file fastGraph_tpl.h.
References gum::isIntegerWithResult().
|
inline |
Scans one ";"-delimited chain, splitting it into node tokens while remembering, for each token, whether it was preceded by "->" (Arc), "<-" (RevArc) or "-" (Edge).
A plain split() cannot preserve this, since it only handles one delimiter at a time.
"-" (not "--") is used for edges: MRF's own fast syntax already uses "--" to list the variables of a single factor (a clique), which is a different construct from a chain of pairwise edges. Reusing "--" here would silently give the same token two incompatible meanings.
Definition at line 96 of file fastGraph_tpl.h.
References Arc, Edge, fastGraphFindDash(), None, RevArc, and gum::trim_copy().
| void gum::detail::fastGraphWalkTokens | ( | const std::vector< std::pair< std::string, FastGraphOp > > & | tokens, |
| std::string_view | desc, | ||
| Resolve | resolve, | ||
| AddArc | addArc, | ||
| AddEdge | addEdge ) |
Walks one already-tokenized chain (see fastGraphTokenize()), resolving each token to a NodeId via resolve and wiring consecutive nodes via addArc / addEdge according to the operator preceding each token.
This is the shared topology grammar behind fastGraph(), BayesNet::fastPrototype() and InfluenceDiagram::fastPrototype(): what a "node" is (a bare graph node, a chance/utility/ decision DiscreteVariable, ...) is entirely delegated to resolve, so callers with no notion of undirected edges (BayesNet, InfluenceDiagram) can simply pass an addEdge that throws.
| tokens | the chain, as produced by fastGraphTokenize(). |
| desc | the full original description, only used to report errors. |
| resolve | NodeId resolve(const std::string& token): gets or creates the node denoted by a raw token. |
| addArc | void addArc(NodeId tail, NodeId head, const std::string& token): wires a directed arc; token is the node that carried the "->"/"<-" operator, for error messages. |
| addEdge | void addEdge(NodeId a, NodeId b, const std::string& token): wires an undirected edge; same token convention. |
| InvalidArc | if desc is malformed (an operator without a following node token). |
Definition at line 176 of file fastGraph_tpl.h.