![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in dot.hpp
.
This class facilitates the creation and rendering of graph descriptions in the DOT language of the Graphviz graph drawing software. This class is fairly rudimentary, and is not intended to implement every feature of the DOT language.
You can create a Dot object, assemble the graph by adding nodes and edges, attributes, labels, colours, subgraphs, and clusters, and retrieve its DOT source code string (Dot::to_string). Write the source code to a file and render it with the Graphviz installation on your system.
Classes | |
struct | Edge |
This nested struct represents an edge in the represented graph. More... | |
struct | Node |
This nested struct represents a node in the represented graph. More... | |
Public Types | |
enum class | Kind { digraph , graph , subgraph } |
The kind of object represented. More... | |
Public Member Functions | |
Dot () | |
Default constructor. | |
Dot (Dot &&) | |
Default move constructor. | |
Dot (Dot const &) | |
Default copy constructor. | |
template<typename Thing> | |
Dot & | add_attr (Thing &&key) |
Add an attribute to the graph. | |
template<typename Thing1, typename Thing2> | |
Dot & | add_attr (Thing1 &&key, Thing2 &&val) |
Add an attribute to the graph. | |
template<typename Thing1, typename Thing2> | |
Edge & | add_edge (Thing1 &&head, Thing2 &&tail) |
Add an edge with given head and tail. | |
template<typename Thing> | |
Node & | add_node (Thing &&thing) |
Add a node to the represented graph. | |
Dot & | add_subgraph (Dot &&subgraph) |
Add a Dot object as a subgraph. | |
Dot & | add_subgraph (Dot const &subgraph) |
Add a Dot object as a subgraph. | |
std::map< std::string, std::string > const & | attrs () const noexcept |
Returns a const reference to the map of attributes. | |
template<typename Thing1, typename Thing2> | |
Edge & | edge (Thing1 &&head, Thing2 &&tail) |
Returns the first edge with given head and tail. | |
std::vector< Edge > const & | edges () const noexcept |
Returns a const reference to the vector of edges. | |
std::vector< Edge > & | edges () noexcept |
Returns a reference to the vector of edges. | |
bool | is_node (std::string const &name) const |
Check if there is a node with a given name. | |
template<typename Thing, typename std::enable_if_t< !std::is_same_v< std::decay_t< Thing >, std::string > >> | |
bool | is_node (Thing &&thing) const |
Check if there is a node with name obtained from an object. | |
Kind | kind () const noexcept |
Get the kind of the represented graph. | |
Dot & | kind (Kind val) noexcept |
Set the kind of the represented graph. | |
std::string const & | name () const noexcept |
Get the current name of the represented graph. | |
Dot & | name (std::string const &val) |
Set the name of the represented graph. | |
template<typename Thing> | |
Node & | node (Thing &&thing) |
Return a node from the represented graph. | |
auto | nodes () const noexcept |
Returns a range object of const references to the current nodes. | |
auto | nodes () noexcept |
Returns a range object of references to the current nodes. | |
Dot & | operator= (Dot &&) |
Default move assignment operator. | |
Dot & | operator= (Dot const &) |
Default copy assignment operator. | |
std::vector< Dot > const & | subgraphs () const noexcept |
Returns a const reference to the vector of subgraphs. | |
std::vector< Dot > & | subgraphs () noexcept |
Returns a reference to the vector of subgraphs. | |
std::string | to_string () const |
Convert a Dot object to a string. | |
Related Symbols | |
(Note that these are not member symbols.) | |
std::string | to_human_readable_repr (Dot::Edge const &e) |
Return a human readable representation of a Dot::Edge object. | |
std::string | to_human_readable_repr (Dot::Node const &n) |
Return a human readable representation of a Dot::Node object. | |
std::string | to_human_readable_repr (Dot const &d) |
Return a human readable representation of a Dot object. | |
std::string | to_human_readable_repr (Dot::Kind const &k, std::string const &sep="::") |
Return a human readable representation of a Dot::Kind object. | |
|
strong |
Enumerator | |
---|---|
digraph | Value indicating that the represented graph has directed edges |
graph | Value indicating that the represented graph has undirected edges |
subgraph | Value indicating that the represented graph is a subgraph of another Dot object. |
|
inline |
This function adds a new attribute, or replaces the value of an existing attribute, of a Dot object. The argument key
is converted to std::string (unless they are std::string, std::string_view, or char const*
already).
Thing | the type of the argument. |
key | the name of the attribute. |
this
.key
or val
are valid in DOT; see the Graphviz documentation for more details.
|
inline |
This function adds a new attribute, or replaces the value of an existing attribute, of a Dot object. The arguments key
and val
are converted to std::string (unless they are std::string, std::string_view, or char const*
already).
Thing1 | the type of the first argument. |
Thing2 | the type of the second argument. |
key | the name of the attribute. |
val | the value of the attribute. |
this
.key
or val
are valid in DOT; see the Graphviz documentation for more details.
|
inline |
This function adds an edge with head and tail obtained from head
and tail
by converting head
and tail
to std::string objects (unless they are std::string, std::string_view, or char const*
already) using std::to_string.
Thing1 | the type of the 1st argument. |
Thing2 | the type of the 2nd argument. |
head | the head of the edge. |
tail | the tail of the edge. |
head
to tail
.LibsemigroupsException | if head or tail does not represent a node in the graph. |
|
inline |
This function adds a node with name obtained from thing
by converting it to a std::string (unless they are std::string, std::string_view, or char const*
already) using std::to_string.
Thing | the type of the argument. |
thing | the object to use as the name of a node. |
LibsemigroupsException | if there is already a node with name std::to_string(thing) . |
This function adds the Dot object subgraph
as a subgraph of this
. The following transformations are performed:
label
attribute of the added subgraph is the name of subgraph
;"cluster_"
prepended;"name_"
prepended (where "name"
is the return value of name);label
attribute of every node in the added subgraph is its original name in subgraph
;constraint
set to false
.subgraph | the Dot object to use as a subgraph. |
this
. This function adds the Dot object subgraph
as a subgraph of this
. The following transformations are performed:
label
attribute of the added subgraph is the name of subgraph
;"cluster_"
prepended;"name_"
prepended (where "name"
is the return value of name);label
attribute of every node in the added subgraph is its original name in subgraph
;constraint
set to false
.subgraph | the Dot object to use as a subgraph. |
this
.
|
inlinenoexcept |
Returns a const reference to a std::map of the current attributes of the represented graph.
noexcept
and is guaranteed never to throw.
|
inline |
This function returns the first edge with head and tail obtained from head
and tail
by converting head
and tail
to std::string objects (unless they are std::string, std::string_view, or char const*
already) using std::to_string.
Thing1 | the type of the 1st argument. |
Thing2 | the type of the 2nd argument. |
head | the head of the edge. |
tail | the tail of the edge. |
head
to tail
.LibsemigroupsException | if head or tail does not represent a node in the graph. |
LibsemigroupsException | if there's no edge from head to tail . |
|
inlinenoexcept |
Returns a const reference to a std::vector of the current edges (Edge objects) in the represented graph.
noexcept
and is guaranteed never to throw.
|
inlinenoexcept |
Returns a reference to a std::vector of the current edges (Edge objects) in the represented graph.
noexcept
and is guaranteed never to throw.
|
inlinenodiscard |
This function returns true
if name
is currently the name of a node in the represented graph and false
otherwise.
name | the name. |
bool
.
|
inlinenodiscard |
This function returns true
if the value returned by std::to_string applied to name
is currently the name of a node in the represented graph and false
otherwise.
Thing | the type of the argument. |
thing | the object that whose string representation might be a node. |
bool
.
|
inlinenoexcept |
noexcept
and is guaranteed never to throw. val | the kind. |
this
.noexcept
and is guaranteed never to throw.
|
inlinenoexcept |
Get the current name of the represented graph.
|
inline |
val | the name. |
this
.
|
inline |
This function returns a reference to a node with name obtained from thing
by converting it to a std::string (unless they are std::string, std::string_view, or char const*
already) using std::to_string.
Thing | the type of the argument. |
thing | the object to use as the name of a node. |
LibsemigroupsException | if there is no node with name std::to_string(thing) . |
|
inlinenoexcept |
Returns a range object of const references for the current nodes in the represented graph; see Ranges for more details.
noexcept
and is guaranteed never to throw.
|
inlinenoexcept |
Returns a range object of references for the current nodes in the represented graph; see Ranges for more details.
noexcept
and is guaranteed never to throw.
|
inlinenoexcept |
Returns a const reference to a std::vector of the current subgraphs (Dot objects) in the represented graph.
noexcept
and is guaranteed never to throw.
|
inlinenoexcept |
Returns a reference to a std::vector of the current subgraphs (Dot objects) in the represented graph.
noexcept
and is guaranteed never to throw. std::string to_string | ( | ) | const |
This function returns the string representation of the Dot object. This string contains a representation of the graph in the DOT language for Graphviz.
|
Return a human readable representation of a Dot object.
d | the Dot object. |
|
Return a human readable representation of a Dot::Kind object.
k | the Dot::Kind object. |
sep | separator to use between "Dot" and "Kind" (defaults to "::"). |
|
staticconstexpr |
An array of default HTML/hex colours.