The Dot class
A representation of a graph in the DOT language of Graphviz.
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.
Contents
A representation of a graph in the DOT language of Graphviz. |
|
|
Overloaded function. |
|
This function adds an edge from the node named head to the node named tail. |
|
This function adds a node with name name. |
This functions adds the |
|
|
Returns a read-only dictionary of the current attributes of the represented graph. |
A list of default HTML/hex colours. |
|
|
Copy a |
|
Returns the edge object with head named head and tail named tail. |
|
Returns a copy of the list of the current edges ( |
|
Check if there is a node with a given name. |
|
Overloaded function. |
|
Overloaded function. |
|
Returns the node object with name name. |
|
Returns a copy of the list of the current nodes in the represented graph. |
Returns a copy of the list of the current subgraphs ( |
|
Convert a |
Full API
- class Dot
- __init__(self: Dot) None
Default constructor that constructs an empty
Dot
object with no nodes, edges, attributes, or subgraphs.
- add_attr(*args, **kwargs)
Overloaded function.
- add_edge(self: Dot, head: str, tail: str) Dot.Edge
This function adds an edge from the node named head to the node named tail.
- Parameters:
- Returns:
a newly created
Dot.Edge
object.- Return type:
- Raises:
LibsemigroupsError – if there is no node named head and/or tail.
- add_node(self: Dot, name: str) Dot.Node
This function adds a node with name name.
- Parameters:
name (str) – the name of the node to add.
- Returns:
a newly created
Dot.Node
object with name name.- Return type:
- Raises:
LibsemigroupsError – if there is already a node with name name.
- add_subgraph(self: Dot, subgraph: Dot) Dot
This functions adds the
Dot
object subgraph as a subgraph of self. The following transformations are performedthe
label
attribute of the added subgraph is theDot.name
of subgraph;the
Dot.name
of the added subgraph has the prefix"cluster_"
added;every node in the added subgraph has the prefix
"name_"
prepended (where"name"
is the return value ofDot.name
);the
label
attribute of every node in the added subgraph is its original name in subgraph;every edge is modified so that its head and tail use the new node names;
every edge has the attribute
constraint
set tofalse
.
- attrs(self: Dot) dict[str, str]
Returns a read-only dictionary of the current attributes of the represented graph.
- property colors
A list of default HTML/hex colours.
- edge(self: Dot, head: str, tail: str) Dot.Edge
Returns the edge object with head named head and tail named tail.
- Parameters:
- Returns:
The edge from the node named head to the node named tail.
- Return type:
- Raises:
LibsemigroupsError – if there is no node named head or no node named tail.
LibsemigroupsError – if there is no edge from head to tail.
- edges(self: Dot) list[Dot.Edge]
Returns a copy of the list of the current edges (
Edge
objects) in the represented graph.
- is_node(self: Dot, name: str) bool
Check if there is a node with a given name.
This function returns
True
if name is currently the name of a node in the represented graph andFalse
otherwise.
- kind(*args, **kwargs)
Overloaded function.
- name(*args, **kwargs)
Overloaded function.
- node(self: Dot, name: str) Dot.Node
Returns the node object with name name.
- Parameters:
name (str) – the name of the node.
- Returns:
The node named name.
- Return type:
- Raises:
LibsemigroupsError – if there is no node named name.
- nodes(self: Dot) list[Dot.Node]
Returns a copy of the list of the current nodes in the represented graph.