![]() |
aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
|
Writes a graph in the dot language, statement after statement, in the order of the calls. More...
#include <agrum/base/core/dot/dotWriter.h>
Public Member Functions | |
| DotWriter (bool directed=true, std::string_view name="") | |
| Starts a graph. | |
| std::string | str () const |
| The graph written so far, closed. It can be called at any moment, and the writer can be used after. | |
Statements | |
| void | graphAttributes (const DotAttributes &attributes) |
| graph [attributes];, the attributes of the graph (does nothing if there is none). | |
| void | nodeDefaults (const DotAttributes &attributes) |
| node [attributes];, the default attributes of the nodes that follow (none : does nothing). | |
| void | edgeDefaults (const DotAttributes &attributes) |
| edge [attributes];, the default attributes of the edges that follow (none : does nothing). | |
| void | graphAttribute (const DotAttribute &attribute) |
| key="value";, an attribute of the graph or of the subgraph being written. | |
| void | node (std::string_view id, const DotAttributes &attributes={}) |
| a node, whose identifier is id (quoted). | |
| void | node (Size id, const DotAttributes &attributes={}) |
| a node designated by a number, written without quotes (graphviz reads it as an identifier). | |
| void | edge (std::string_view from, std::string_view to, const DotAttributes &attributes={}) |
| an edge from from to to (-> in a directed graph, -- in an undirected one). | |
| void | edge (Size from, Size to, const DotAttributes &attributes={}) |
| an edge between two nodes designated by numbers, written without quotes. | |
| void | beginSubgraph (std::string_view name, const DotAttributes &attributes={}) |
| Opens a subgraph : subgraph "name" { key="value"; ... . | |
| void | endSubgraph () |
| Closes the last subgraph that is open. | |
Static Public Member Functions | |
Formatting | |
| static std::string | quote (std::string_view text) |
| text between double quotes, in which ", \, line feed and carriage return are escaped. | |
| static std::string | number (double value) |
| The shortest text that reads back as value (0.5, 1, 1e-05). | |
Private Member Functions | |
| std::string | _indent_ () const |
| void | _defaults_ (const char *keyword, const DotAttributes &attributes) |
| void | _node_ (const std::string &id, const DotAttributes &attributes) |
| void | _edge_ (const std::string &from, const std::string &to, const DotAttributes &attributes) |
Static Private Member Functions | |
| static std::string | _attributes_ (const DotAttributes &attributes) |
| static std::string | _attribute_ (const DotAttribute &attribute) |
Private Attributes | |
| std::string | _buffer_ |
| bool | _directed_ |
| int | _depth_ {0} |
Writes a graph in the dot language, statement after statement, in the order of the calls.
The names of the nodes, the labels and the values of the attributes are quoted and escaped, so that any text gives a well formed graph. The keys of the attributes are checked (letters, digits and underscores, not starting with a digit).
Errors :
Definition at line 100 of file dotWriter.h.
|
explicit |
Starts a graph.
| directed | true for a digraph (edges ->), false for a graph (edges --). |
| name | the name of the graph, written quoted ; none if empty. |
Definition at line 67 of file dotWriter.cpp.
References _buffer_, and _directed_.
|
staticprivate |
Definition at line 101 of file dotWriter.cpp.
References GUM_ERROR, gum::dot::DotAttribute::key, quote(), gum::dot::DotAttribute::value, and gum::dot::DotAttribute::verbatim.
Referenced by _attributes_(), beginSubgraph(), and graphAttribute().
|
staticprivate |
Definition at line 108 of file dotWriter.cpp.
References _attribute_().
Referenced by _defaults_(), _edge_(), and _node_().
|
private |
Definition at line 117 of file dotWriter.cpp.
References _attributes_(), _buffer_, and _indent_().
Referenced by edgeDefaults(), graphAttributes(), and nodeDefaults().
|
private |
Definition at line 140 of file dotWriter.cpp.
References _attributes_(), _buffer_, _directed_, and _indent_().
Referenced by edge(), and edge().
|
private |
Definition at line 99 of file dotWriter.cpp.
References _depth_.
Referenced by _defaults_(), _edge_(), _node_(), beginSubgraph(), endSubgraph(), and graphAttribute().
|
private |
Definition at line 134 of file dotWriter.cpp.
References _attributes_(), _buffer_, and _indent_().
Referenced by node(), and node().
| void gum::dot::DotWriter::beginSubgraph | ( | std::string_view | name, |
| const DotAttributes & | attributes = {} ) |
Opens a subgraph : subgraph "name" { key="value"; ... .
Its statements are the ones written until endSubgraph(). Graphviz draws it as a cluster if the name starts with cluster.
| name | the name of the subgraph (quoted), anonymous if empty. |
| attributes | the attributes of the subgraph. |
Definition at line 165 of file dotWriter.cpp.
References _attribute_(), _buffer_, _depth_, _indent_(), and quote().
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), and gum::PDAG::toDot().
| void gum::dot::DotWriter::edge | ( | Size | from, |
| Size | to, | ||
| const DotAttributes & | attributes = {} ) |
an edge between two nodes designated by numbers, written without quotes.
Definition at line 161 of file dotWriter.cpp.
References _edge_().
| void gum::dot::DotWriter::edge | ( | std::string_view | from, |
| std::string_view | to, | ||
| const DotAttributes & | attributes = {} ) |
an edge from from to to (-> in a directed graph, -- in an undirected one).
Definition at line 157 of file dotWriter.cpp.
References _edge_(), and quote().
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::DiGraph::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::MixedGraph::toDot(), gum::PAG::toDot(), gum::PDAG::toDot(), gum::UndiGraph::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
| void gum::dot::DotWriter::edgeDefaults | ( | const DotAttributes & | attributes | ) |
edge [attributes];, the default attributes of the edges that follow (none : does nothing).
Definition at line 128 of file dotWriter.cpp.
References _defaults_().
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph(), and gum::dot::writePreamble().
| void gum::dot::DotWriter::endSubgraph | ( | ) |
Closes the last subgraph that is open.
Definition at line 177 of file dotWriter.cpp.
References _buffer_, _depth_, _indent_(), and GUM_ERROR.
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), and gum::PDAG::toDot().
| void gum::dot::DotWriter::graphAttribute | ( | const DotAttribute & | attribute | ) |
key="value";, an attribute of the graph or of the subgraph being written.
Definition at line 130 of file dotWriter.cpp.
References _attribute_(), _buffer_, and _indent_().
| void gum::dot::DotWriter::graphAttributes | ( | const DotAttributes & | attributes | ) |
graph [attributes];, the attributes of the graph (does nothing if there is none).
Definition at line 122 of file dotWriter.cpp.
References _defaults_().
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), and gum::dot::writePreamble().
| void gum::dot::DotWriter::node | ( | Size | id, |
| const DotAttributes & | attributes = {} ) |
a node designated by a number, written without quotes (graphviz reads it as an identifier).
Definition at line 152 of file dotWriter.cpp.
References _node_().
| void gum::dot::DotWriter::node | ( | std::string_view | id, |
| const DotAttributes & | attributes = {} ) |
a node, whose identifier is id (quoted).
Definition at line 148 of file dotWriter.cpp.
References _node_(), and quote().
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph(), and gum::NodeGraphPart::writeDotNode().
| void gum::dot::DotWriter::nodeDefaults | ( | const DotAttributes & | attributes | ) |
node [attributes];, the default attributes of the nodes that follow (none : does nothing).
Definition at line 126 of file dotWriter.cpp.
References _defaults_().
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::dot::writePreamble().
|
static |
The shortest text that reads back as value (0.5, 1, 1e-05).
Definition at line 93 of file dotWriter.cpp.
Referenced by gum::dot::arcAttributes(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
|
static |
text between double quotes, in which ", \, line feed and carriage return are escaped.
Definition at line 76 of file dotWriter.cpp.
Referenced by _attribute_(), beginSubgraph(), edge(), and node().
| std::string gum::dot::DotWriter::str | ( | ) | const |
The graph written so far, closed. It can be called at any moment, and the writer can be used after.
Definition at line 183 of file dotWriter.cpp.
References _buffer_, _depth_, and GUM_ERROR.
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::DiGraph::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::MixedGraph::toDot(), gum::PDAG::toDot(), gum::UndiGraph::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
|
private |
Definition at line 163 of file dotWriter.h.
Referenced by DotWriter(), _defaults_(), _edge_(), _node_(), beginSubgraph(), endSubgraph(), graphAttribute(), and str().
|
private |
Definition at line 165 of file dotWriter.h.
Referenced by _indent_(), beginSubgraph(), endSubgraph(), and str().
|
private |
Definition at line 164 of file dotWriter.h.
Referenced by DotWriter(), and _edge_().