aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
dotOptions.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
48#ifndef GUM_DOT_OPTIONS_H
49#define GUM_DOT_OPTIONS_H
50
51#include <map>
52#include <optional>
53#include <string>
54#include <utility>
55#include <vector>
56
57#include <agrum/agrum.h>
58
60
61namespace gum::dot {
62
67 std::string bgColor;
69 std::string fgColor;
71 std::string label;
73 std::string tooltip;
76 };
77
80 std::string color;
81 std::optional< double > width;
82 std::string label;
83 std::string tooltip;
86 };
87
110 class GUM_SHARED_PUBLIC DotOptions {
111 public:
115 void setSize(const std::string& size);
117 void setRankDir(const std::string& rankDir);
119 void setLayout(const std::string& layout);
121 void setLabel(const std::string& label);
122
123 const std::string& size() const;
124 const std::string& rankDir() const;
125 const std::string& layout() const;
126 const std::string& label() const;
128
131 void setNodeBgColor(Size node, const std::string& color);
132 void setNodeFgColor(Size node, const std::string& color);
133 void setNodeLabel(Size node, const std::string& label);
134 void setNodeTooltip(Size node, const std::string& tooltip);
137 const std::string& key,
138 const std::string& value,
139 bool verbatim = false);
140
142 const DotNodeOptions* node(Size node) const;
144
147 void setArcColor(Size tail, Size head, const std::string& color);
149 void setArcWidth(Size tail, Size head, double width);
150 void setArcLabel(Size tail, Size head, const std::string& label);
151 void setArcTooltip(Size tail, Size head, const std::string& tooltip);
153 void setArcAttribute(Size tail,
154 Size head,
155 const std::string& key,
156 const std::string& value,
157 bool verbatim = false);
158
160 const DotArcOptions* arc(Size tail, Size head) const;
163 const DotArcOptions* edge(Size a, Size b) const;
165
169 void setFactorBgColor(const std::vector< Size >& variables, const std::string& color);
170 void setFactorFgColor(const std::vector< Size >& variables, const std::string& color);
171 void setFactorLabel(const std::vector< Size >& variables, const std::string& label);
172 void setFactorTooltip(const std::vector< Size >& variables, const std::string& tooltip);
175 void setFactorAttribute(const std::vector< Size >& variables,
176 const std::string& key,
177 const std::string& value,
178 bool verbatim = false);
179
182 const DotNodeOptions* factor(const std::vector< Size >& variables) const;
184
186 bool empty() const;
187
188 private:
189 std::string _size_;
190 std::string _rankDir_;
191 std::string _layout_;
192 std::string _label_;
193
194 std::map< Size, DotNodeOptions > _nodes_;
195 std::map< std::pair< Size, Size >, DotArcOptions > _arcs_;
196 std::map< std::vector< Size >, DotNodeOptions > _factors_;
197
198 // the variables of a factor, sorted and without duplicate
199 static std::vector< Size > _key_(std::vector< Size > variables);
200 };
201
202} // namespace gum::dot
203
204#endif // GUM_DOT_OPTIONS_H
The options given to a toDot(const DotOptions&).
Definition dotOptions.h:110
void setArcColor(Size tail, Size head, const std::string &color)
std::map< std::pair< Size, Size >, DotArcOptions > _arcs_
Definition dotOptions.h:195
void setRankDir(const std::string &rankDir)
direction of the layout, TB or LR
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
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
const std::string & layout() const
direction of the layout, TB or LR
void setArcWidth(Size tail, Size head, double width)
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
void setNodeBgColor(Size node, const std::string &color)
any other attribute of the node ; 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 std::string & label() const
direction of the layout, TB or LR
const std::string & size() const
direction of the layout, TB or LR
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
std::map< std::vector< Size >, DotNodeOptions > _factors_
Definition dotOptions.h:196
void setArcTooltip(Size tail, Size head, const std::string &tooltip)
void setLabel(const std::string &label)
label of the graph (by default, the name of the graph if it has one)
std::map< Size, DotNodeOptions > _nodes_
Definition dotOptions.h:194
std::string _rankDir_
Definition dotOptions.h:190
void setNodeTooltip(Size node, const std::string &tooltip)
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
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
bool empty() const
true if nothing was given
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),...
static std::vector< Size > _key_(std::vector< Size > variables)
void setLayout(const std::string &layout)
graphviz layout engine
void setNodeFgColor(Size node, const std::string &color)
any other attribute of the node ; written as is if verbatim, see DotAttribute
std::string _label_
Definition dotOptions.h:192
const std::string & rankDir() const
direction of the layout, TB or LR
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
std::string _layout_
Definition dotOptions.h:191
const DotNodeOptions * node(Size node) const
the options of a node, or nullptr if none was given for it
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 setArcLabel(Size tail, Size head, const std::string &label)
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 setNodeLabel(Size node, const std::string &label)
any other attribute of the node ; written as is if verbatim, see DotAttribute
A minimal writer of graphs in the dot language of graphviz.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
std::vector< DotAttribute > DotAttributes
a list of attributes
Definition dotWriter.h:74
the options of an arc or an edge : an empty text (no value for the width) means "not given"
Definition dotOptions.h:79
std::optional< double > width
Definition dotOptions.h:81
DotAttributes attributes
other attributes, written after the ones above
Definition dotOptions.h:85
the options of a node : an empty text means "not given", so that the value of the configuration is us...
Definition dotOptions.h:65
std::string fgColor
font color (if only the background is given, the font color is adaptive against it)
Definition dotOptions.h:69
std::string tooltip
text displayed when the mouse is over the node
Definition dotOptions.h:73
std::string bgColor
background color
Definition dotOptions.h:67
DotAttributes attributes
other attributes, written after the ones above
Definition dotOptions.h:75
std::string label
text displayed in the node
Definition dotOptions.h:71