aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::dot::DotOptions Class Reference

The options given to a toDot(const DotOptions&). More...

#include <agrum/base/core/dot/dotOptions.h>

Public Member Functions

bool empty () const
 true if nothing was given
Graph

size of the graph, in inches (5, or 12! for an exact size)

void setSize (const std::string &size)
 direction of the layout, TB or LR
void setRankDir (const std::string &rankDir)
 direction of the layout, TB or LR
void setLayout (const std::string &layout)
 graphviz layout engine
void setLabel (const std::string &label)
 label of the graph (by default, the name of the graph if it has one)
const std::string & size () const
 direction of the layout, TB or LR
const std::string & rankDir () const
 direction of the layout, TB or LR
const std::string & layout () const
 direction of the layout, TB or LR
const std::string & label () const
 direction of the layout, TB or LR
Nodes
void setNodeBgColor (Size node, const std::string &color)
 any other attribute of the node ; written as is if verbatim, see DotAttribute
void setNodeFgColor (Size node, const std::string &color)
 any other attribute of the node ; written as is if verbatim, see DotAttribute
void setNodeLabel (Size node, const std::string &label)
 any other attribute of the node ; written as is if verbatim, see DotAttribute
void setNodeTooltip (Size node, const std::string &tooltip)
 any other attribute of the node ; written as is if verbatim, see DotAttribute
void setNodeAttribute (Size node, const std::string &key, const std::string &value, bool verbatim=false)
 any other attribute of the node ; written as is if verbatim, see DotAttribute
const DotNodeOptions * node (Size node) const
 the options of a node, or nullptr if none was given for it
Arcs and edges
void setArcColor (Size tail, Size head, const std::string &color)
void setArcWidth (Size tail, Size head, double width)
void setArcLabel (Size tail, Size head, const std::string &label)
void setArcTooltip (Size tail, Size head, const std::string &tooltip)
void setArcAttribute (Size tail, Size head, const std::string &key, const std::string &value, bool verbatim=false)
 any other attribute of the arc ; written as is if verbatim, see DotAttribute
const DotArcOptions * arc (Size tail, Size head) const
 the options of the arc from tail to head, or nullptr if none was given for it
const DotArcOptions * edge (Size a, Size b) const
 the options of the undirected edge between a and b, given for (a, b) or for (b, a), or nullptr
Factors of a factor graph

A factor is designated by the identifiers of its variables, in any order.

void setFactorBgColor (const std::vector< Size > &variables, const std::string &color)
 any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute
void setFactorFgColor (const std::vector< Size > &variables, const std::string &color)
 any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute
void setFactorLabel (const std::vector< Size > &variables, const std::string &label)
 any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute
void setFactorTooltip (const std::vector< Size > &variables, const std::string &tooltip)
 any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute
void setFactorAttribute (const std::vector< Size > &variables, const std::string &key, const std::string &value, bool verbatim=false)
 any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute
const DotNodeOptions * factor (const std::vector< Size > &variables) const
 the options of the factor on these variables (in any order), or nullptr if none was given

Static Private Member Functions

static std::vector< Size > _key_ (std::vector< Size > variables)

Private Attributes

std::string _size_
std::string _rankDir_
std::string _layout_
std::string _label_
std::map< Size, DotNodeOptions > _nodes_
std::map< std::pair< Size, Size >, DotArcOptions > _arcs_
std::map< std::vector< Size >, DotNodeOptions > _factors_

Detailed Description

The options given to a toDot(const DotOptions&).

What is not given is taken from the configuration (see gum::dot::DotStyle). The nodes are designated by their identifier (NodeId), the arcs by the identifiers of their tail and their head; an undirected edge is designated by its two ends, given in any order. The options are filled with setters, one value at a time, so that they can be filled from any language (colors computed from a color map for instance).

options.setSize("12!");
options.setNodeBgColor(0, "#FF7F64");
options.setArcWidth(0, 1, 2.5);
auto dot = bn.toDot(options);
The options given to a toDot(const DotOptions&).
Definition dotOptions.h:110
void setArcWidth(Size tail, Size head, double width)
void setNodeBgColor(Size node, const std::string &color)
any other attribute of the node ; written as is if verbatim, see DotAttribute
void setSize(const std::string &size)
direction of the layout, TB or LR

Errors : gum::InvalidArgument for a width that is negative or not a finite number.

Definition at line 110 of file dotOptions.h.

Member Function Documentation

◆ _key_()

std::vector< Size > gum::dot::DotOptions::_key_ ( std::vector< Size > variables)
staticprivate

Definition at line 137 of file dotOptions.cpp.

137 {
138 std::sort(variables.begin(), variables.end());
139 variables.erase(std::unique(variables.begin(), variables.end()), variables.end());
140 return variables;
141 }

Referenced by factor(), setFactorAttribute(), setFactorBgColor(), setFactorFgColor(), setFactorLabel(), and setFactorTooltip().

Here is the caller graph for this function:

◆ arc()

const DotArcOptions * gum::dot::DotOptions::arc ( Size tail,
Size head ) const

the options of the arc from tail to head, or nullptr if none was given for it

Definition at line 127 of file dotOptions.cpp.

127 {
128 const auto it = _arcs_.find({tail, head});
129 return it == _arcs_.end() ? nullptr : &it->second;
130 }
std::map< std::pair< Size, Size >, DotArcOptions > _arcs_
Definition dotOptions.h:195

References _arcs_.

Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), edge(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::DiGraph::toDot(), gum::EssentialGraph::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::MixedGraph::toDot(), and gum::PDAG::toDot().

Here is the caller graph for this function:

◆ edge()

const DotArcOptions * gum::dot::DotOptions::edge ( Size a,
Size b ) const

the options of the undirected edge between a and b, given for (a, b) or for (b, a), or nullptr

Definition at line 132 of file dotOptions.cpp.

132 {
133 if (const auto* options = arc(a, b)) return options;
134 return arc(b, a);
135 }
const DotArcOptions * arc(Size tail, Size head) const
the options of the arc from tail to head, or nullptr if none was given for it

References arc().

Referenced by gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::MixedGraph::toDot(), gum::PAG::toDot(), gum::PDAG::toDot(), and gum::UndiGraph::toDot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

bool gum::dot::DotOptions::empty ( ) const

true if nothing was given

Definition at line 174 of file dotOptions.cpp.

174 {
175 return _size_.empty() && _rankDir_.empty() && _layout_.empty() && _label_.empty()
176 && _nodes_.empty() && _arcs_.empty() && _factors_.empty();
177 }
std::map< std::vector< Size >, DotNodeOptions > _factors_
Definition dotOptions.h:196
std::map< Size, DotNodeOptions > _nodes_
Definition dotOptions.h:194
std::string _rankDir_
Definition dotOptions.h:190
std::string _label_
Definition dotOptions.h:192
std::string _layout_
Definition dotOptions.h:191

References _arcs_, _factors_, _label_, _layout_, _nodes_, _rankDir_, and _size_.

◆ factor()

const DotNodeOptions * gum::dot::DotOptions::factor ( const std::vector< Size > & variables) const

the options of the factor on these variables (in any order), or nullptr if none was given

Definition at line 169 of file dotOptions.cpp.

169 {
170 const auto it = _factors_.find(_key_(variables));
171 return it == _factors_.end() ? nullptr : &it->second;
172 }
static std::vector< Size > _key_(std::vector< Size > variables)

References _factors_, and _key_().

Referenced by gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ label()

const std::string & gum::dot::DotOptions::label ( ) const

direction of the layout, TB or LR

Definition at line 69 of file dotOptions.cpp.

69{ return _label_; }

References _label_.

Referenced by setArcLabel(), setFactorLabel(), setLabel(), setNodeLabel(), and gum::dot::writePreamble().

Here is the caller graph for this function:

◆ layout()

const std::string & gum::dot::DotOptions::layout ( ) const

direction of the layout, TB or LR

Definition at line 67 of file dotOptions.cpp.

67{ return _layout_; }

References _layout_.

Referenced by setLayout(), and gum::dot::writePreamble().

Here is the caller graph for this function:

◆ node()

const DotNodeOptions * gum::dot::DotOptions::node ( Size node) const

the options of a node, or nullptr if none was given for it

Definition at line 94 of file dotOptions.cpp.

94 {
95 const auto it = _nodes_.find(node);
96 return it == _nodes_.end() ? nullptr : &it->second;
97 }
const DotNodeOptions * node(Size node) const
the options of a node, or nullptr if none was given for it

References _nodes_, and node().

Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), node(), setNodeAttribute(), setNodeBgColor(), setNodeFgColor(), setNodeLabel(), setNodeTooltip(), 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rankDir()

const std::string & gum::dot::DotOptions::rankDir ( ) const

direction of the layout, TB or LR

Definition at line 65 of file dotOptions.cpp.

65{ return _rankDir_; }

References _rankDir_.

Referenced by setRankDir(), and gum::dot::writePreamble().

Here is the caller graph for this function:

◆ setArcAttribute()

void gum::dot::DotOptions::setArcAttribute ( Size tail,
Size head,
const std::string & key,
const std::string & value,
bool verbatim = false )

any other attribute of the arc ; written as is if verbatim, see DotAttribute

Definition at line 119 of file dotOptions.cpp.

123 {
124 _arcs_[{tail, head}].attributes.push_back({key, value, verbatim});
125 }

References _arcs_.

◆ setArcColor()

void gum::dot::DotOptions::setArcColor ( Size tail,
Size head,
const std::string & color )
Parameters
widththe width of the line, at least 0

Definition at line 99 of file dotOptions.cpp.

99 {
100 _arcs_[{tail, head}].color = color;
101 }

References _arcs_.

◆ setArcLabel()

void gum::dot::DotOptions::setArcLabel ( Size tail,
Size head,
const std::string & label )
Parameters
widththe width of the line, at least 0

Definition at line 111 of file dotOptions.cpp.

111 {
112 _arcs_[{tail, head}].label = label;
113 }
const std::string & label() const
direction of the layout, TB or LR

References _arcs_, and label().

Here is the call graph for this function:

◆ setArcTooltip()

void gum::dot::DotOptions::setArcTooltip ( Size tail,
Size head,
const std::string & tooltip )
Parameters
widththe width of the line, at least 0

Definition at line 115 of file dotOptions.cpp.

115 {
116 _arcs_[{tail, head}].tooltip = tooltip;
117 }

References _arcs_.

◆ setArcWidth()

void gum::dot::DotOptions::setArcWidth ( Size tail,
Size head,
double width )
Parameters
widththe width of the line, at least 0

Definition at line 103 of file dotOptions.cpp.

103 {
104 if (!std::isfinite(width) || width < 0) {
105 GUM_ERROR(InvalidArgument,
106 "The width of an arc must be a finite number, at least 0 (not " << width << ").")
107 }
108 _arcs_[{tail, head}].width = width;
109 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References _arcs_, and GUM_ERROR.

◆ setFactorAttribute()

void gum::dot::DotOptions::setFactorAttribute ( const std::vector< Size > & variables,
const std::string & key,
const std::string & value,
bool verbatim = false )

any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute

Definition at line 162 of file dotOptions.cpp.

165 {
166 _factors_[_key_(variables)].attributes.push_back({key, value, verbatim});
167 }

References _factors_, and _key_().

Here is the call graph for this function:

◆ setFactorBgColor()

void gum::dot::DotOptions::setFactorBgColor ( const std::vector< Size > & variables,
const std::string & color )

any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute

Definition at line 143 of file dotOptions.cpp.

144 {
145 _factors_[_key_(variables)].bgColor = color;
146 }

References _factors_, and _key_().

Here is the call graph for this function:

◆ setFactorFgColor()

void gum::dot::DotOptions::setFactorFgColor ( const std::vector< Size > & variables,
const std::string & color )

any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute

Definition at line 148 of file dotOptions.cpp.

149 {
150 _factors_[_key_(variables)].fgColor = color;
151 }

References _factors_, and _key_().

Here is the call graph for this function:

◆ setFactorLabel()

void gum::dot::DotOptions::setFactorLabel ( const std::vector< Size > & variables,
const std::string & label )

any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute

Definition at line 153 of file dotOptions.cpp.

153 {
154 _factors_[_key_(variables)].label = label;
155 }

References _factors_, _key_(), and label().

Here is the call graph for this function:

◆ setFactorTooltip()

void gum::dot::DotOptions::setFactorTooltip ( const std::vector< Size > & variables,
const std::string & tooltip )

any other attribute of the node of the factor ; written as is if verbatim, see DotAttribute

Definition at line 157 of file dotOptions.cpp.

158 {
159 _factors_[_key_(variables)].tooltip = tooltip;
160 }

References _factors_, and _key_().

Here is the call graph for this function:

◆ setLabel()

void gum::dot::DotOptions::setLabel ( const std::string & label)

label of the graph (by default, the name of the graph if it has one)

Definition at line 61 of file dotOptions.cpp.

61{ _label_ = label; }

References _label_, and label().

Here is the call graph for this function:

◆ setLayout()

void gum::dot::DotOptions::setLayout ( const std::string & layout)

graphviz layout engine

Definition at line 59 of file dotOptions.cpp.

59{ _layout_ = layout; }
const std::string & layout() const
direction of the layout, TB or LR

References _layout_, and layout().

Here is the call graph for this function:

◆ setNodeAttribute()

void gum::dot::DotOptions::setNodeAttribute ( Size node,
const std::string & key,
const std::string & value,
bool verbatim = false )

any other attribute of the node ; written as is if verbatim, see DotAttribute

Definition at line 87 of file dotOptions.cpp.

90 {
91 _nodes_[node].attributes.push_back({key, value, verbatim});
92 }

References _nodes_, and node().

Here is the call graph for this function:

◆ setNodeBgColor()

void gum::dot::DotOptions::setNodeBgColor ( Size node,
const std::string & color )

any other attribute of the node ; written as is if verbatim, see DotAttribute

Definition at line 71 of file dotOptions.cpp.

71 {
72 _nodes_[node].bgColor = color;
73 }

References _nodes_, and node().

Here is the call graph for this function:

◆ setNodeFgColor()

void gum::dot::DotOptions::setNodeFgColor ( Size node,
const std::string & color )

any other attribute of the node ; written as is if verbatim, see DotAttribute

Definition at line 75 of file dotOptions.cpp.

75 {
76 _nodes_[node].fgColor = color;
77 }

References _nodes_, and node().

Here is the call graph for this function:

◆ setNodeLabel()

void gum::dot::DotOptions::setNodeLabel ( Size node,
const std::string & label )

any other attribute of the node ; written as is if verbatim, see DotAttribute

Definition at line 79 of file dotOptions.cpp.

79 {
80 _nodes_[node].label = label;
81 }

References _nodes_, label(), and node().

Here is the call graph for this function:

◆ setNodeTooltip()

void gum::dot::DotOptions::setNodeTooltip ( Size node,
const std::string & tooltip )

any other attribute of the node ; written as is if verbatim, see DotAttribute

Definition at line 83 of file dotOptions.cpp.

83 {
84 _nodes_[node].tooltip = tooltip;
85 }

References _nodes_, and node().

Here is the call graph for this function:

◆ setRankDir()

void gum::dot::DotOptions::setRankDir ( const std::string & rankDir)

direction of the layout, TB or LR

Definition at line 57 of file dotOptions.cpp.

57{ _rankDir_ = rankDir; }
const std::string & rankDir() const
direction of the layout, TB or LR

References _rankDir_, and rankDir().

Here is the call graph for this function:

◆ setSize()

void gum::dot::DotOptions::setSize ( const std::string & size)

direction of the layout, TB or LR

Definition at line 55 of file dotOptions.cpp.

55{ _size_ = size; }
const std::string & size() const
direction of the layout, TB or LR

References _size_, and size().

Here is the call graph for this function:

◆ size()

const std::string & gum::dot::DotOptions::size ( ) const

direction of the layout, TB or LR

Definition at line 63 of file dotOptions.cpp.

63{ return _size_; }

References _size_.

Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), setSize(), and gum::dot::writePreamble().

Here is the caller graph for this function:

Member Data Documentation

◆ _arcs_

std::map< std::pair< Size, Size >, DotArcOptions > gum::dot::DotOptions::_arcs_
private

◆ _factors_

std::map< std::vector< Size >, DotNodeOptions > gum::dot::DotOptions::_factors_
private

◆ _label_

std::string gum::dot::DotOptions::_label_
private

Definition at line 192 of file dotOptions.h.

Referenced by empty(), label(), and setLabel().

◆ _layout_

std::string gum::dot::DotOptions::_layout_
private

Definition at line 191 of file dotOptions.h.

Referenced by empty(), layout(), and setLayout().

◆ _nodes_

std::map< Size, DotNodeOptions > gum::dot::DotOptions::_nodes_
private

◆ _rankDir_

std::string gum::dot::DotOptions::_rankDir_
private

Definition at line 190 of file dotOptions.h.

Referenced by empty(), rankDir(), and setRankDir().

◆ _size_

std::string gum::dot::DotOptions::_size_
private

Definition at line 189 of file dotOptions.h.

Referenced by empty(), setSize(), and size().


The documentation for this class was generated from the following files: