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
Dotobject 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.Edgeobject.- 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.Nodeobject 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
Dotobject subgraph as a subgraph of self. The following transformations are performedthe
labelattribute of the added subgraph is theDot.nameof subgraph;the
Dot.nameof 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
labelattribute 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
constraintset 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 (
Edgeobjects) in the represented graph.
- is_node(self: Dot, name: str) bool
Check if there is a node with a given name.
This function returns
Trueif name is currently the name of a node in the represented graph andFalseotherwise.
- 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.