galactic.algebras.relational.renderer#
Defines renderers for relational algebra visualizations.
Classes
Renderers:
GraphRendererallows rendering of graphviz attributesNodeRendererfor rendering graphviz attributes of nodes in a graphEdgeRendererfor rendering graphviz attributes of edges in a graphSagittalDiagramRendererfor rendering of graphviz attributes in sagittal diagrams
Graph visualizations:
Tables:
- class GraphRenderer(**data)#
Bases:
Resource,Generic[_E,_F]Renders Graphviz graph attributes.
Notes
See https://www.graphviz.org/doc/info/attrs.html for available attributes.
- add_source(elem, domain, co_domain, *, index=None, current=False, successors=None, predecessors=None)#
Add a source node to the graph.
- Parameters:
elem (
TypeVar(_E)) β The source element to addindex (
int|None, default:None) β The index of the sourcecurrent (
bool, default:False) β Whether the element is the current onedomain (
Collection[TypeVar(_E)]) β The domainco_domain (
Collection[TypeVar(_F)]) β The co-domainsuccessors (
Collection[TypeVar(_F)] |None, default:None) β The successors of the sourcepredecessors (
Collection[TypeVar(_F)] |None, default:None) β The predecessors of the source
- Return type:
- add_destination(elem, domain, co_domain, *, index=None, current=False, successors=None, predecessors=None)#
Add a destination node to the graph.
- Parameters:
elem (
TypeVar(_F)) β The destination element to addindex (
int|None, default:None) β The index of the destinationcurrent (
bool, default:False) β Whether the element is the current onedomain (
Collection[TypeVar(_E)]) β The domainco_domain (
Collection[TypeVar(_F)]) β The co-domainsuccessors (
Collection[TypeVar(_E)] |None, default:None) β The successors of the destinationpredecessors (
Collection[TypeVar(_E)] |None, default:None) β The predecessors of the destination
- Return type:
- add_edge(source, destination, domain, co_domain, *, successors=None, predecessors=None)#
Add an edge to the graph.
- Parameters:
source (
TypeVar(_E)) β The source of the edgedestination (
TypeVar(_F)) β The destination of the edgerelation β The relation
successors (
Collection[TypeVar(_F)] |None, default:None) β The successors of the source (including the current destination)predecessors (
Collection[TypeVar(_E)] |None, default:None) β The predecessors of the destination (including the current source)
- Return type:
- graph_attributes()#
Return the Graphviz attributes for the graph.
- node_attributes()#
Return the common attributes for the nodes.
- edge_attributes()#
Return the common attributes for the edges.
- class NodeRenderer(**data)#
Bases:
Resource,Generic[_E,_F]Renders Graphviz nodes.
Notes
See https://www.graphviz.org/doc/info/attrs.html for available attributes.
- attributes(elem, domain, co_domain, *, index=None, current=False, successors=None, predecessors=None)#
Return a dictionary of Graphviz attributes for a node.
- Parameters:
elem (
TypeVar(_E)) β The element to renderindex (
int|None, default:None) β The index of the elementcurrent (
bool, default:False) β Whether the element is the current onedomain (
Collection[TypeVar(_E)]) β The domainco_domain (
Collection[TypeVar(_F)]) β The co-domainsuccessors (
Collection[TypeVar(_F)] |None, default:None) β The successors of the elementpredecessors (
Collection[TypeVar(_F)] |None, default:None) β The predecessors of the element
- Returns:
A dictionary of Graphviz attributes
- Return type:
- class EdgeRenderer(**data)#
Bases:
Resource,Generic[_E,_F]Renders Graphviz edge attributes.
Notes
See https://www.graphviz.org/doc/info/attrs.html for available attributes.
- attributes(source, destination, domain, co_domain, *, successors=None, predecessors=None)#
Return a dictionary of Graphviz attributes for an edge.
- Parameters:
source (
TypeVar(_E)) β The source of the edgedestination (
TypeVar(_F)) β The destination of the edgedomain (
Collection[TypeVar(_E)]) β The domainco_domain (
Collection[TypeVar(_F)]) β The co-domainsuccessors (
Collection[TypeVar(_F)] |None, default:None) β The successors of the source (including the current destination)predecessors (
Collection[TypeVar(_E)] |None, default:None) β The predecessors of the destination (including the current source)
- Returns:
A dictionary of Graphviz attributes.
- Return type:
- class SagittalDiagramRenderer(**data)#
Bases:
GraphRenderer,Generic[_E,_F]Renders attributes for sagittal diagrams.
Notes
See https://www.graphviz.org/doc/info/attrs.html for available attributes.
- graph_attributes()#
Return the Graphviz attributes for the graph.
- class SagittalDiagramDrawer(**data)#
Bases:
Resource,Generic[_E,_F]Draws sagittal diagrams.
Useful for visualizing binary relations in Jupyter notebooks.
- Parameters:
graph_renderer β The graph renderer
domain_renderer β The domain renderer
co_domain_renderer β The codomain renderer
edge_renderer β The edge renderer
- export(relation, path)#
Render the diagram in a file.
- Parameters:
relation (
BinaryRelation[TypeVar(_E),TypeVar(_F)]) β The relationpath (
Path) β A file path.
- Return type:
- draw(relation)#
Draw the diagram.
- Parameters:
relation (
BinaryRelation[TypeVar(_E),TypeVar(_F)]) β The relation to draw- Returns:
The diagram.
- Return type:
SagittalDiagram[TypeVar(_E),TypeVar(_F)]
- class SagittalDiagram(relation, drawer)#
Bases:
Generic[_E,_F]Draws sagittal diagrams.
Useful for visualizing binary relations in Jupyter notebooks.
- Parameters:
relation (
BinaryRelation[TypeVar(_E),TypeVar(_F)]) β The binary relationdrawer (
SagittalDiagramDrawer) β The drawer
- property relation: BinaryRelation[_E, _F]#
Get the relation.
- Returns:
The underlying relation
- Return type:
BinaryRelation[_E, _F]
- render(path)#
Render the diagram in a file.
- pipe(output='svg')#
Pipe the diagram.
- property digraph: Digraph#
Get the Graphviz Digraph for the diagram.
- Returns:
The digraph
- Return type:
Digraph
- class EndoDiagramDrawer(**data)#
Bases:
Resource,Generic[_E]Draws endo diagrams.
Useful for visualizing endo-relations in Jupyter notebooks.
- Parameters:
graph_renderer β The graph renderer
domain_renderer β The domain renderer
edge_renderer β The edge renderer
- export(relation, path)#
Render the diagram in a file.
- Parameters:
relation (
EndoRelation[TypeVar(_E)]) β The relation.path (
Path) β A file path.
- Return type:
- draw(relation)#
Draw the diagram.
- Parameters:
relation (
EndoRelation[TypeVar(_E)]) β The relation to draw- Returns:
The diagram.
- Return type:
EndoDiagram[TypeVar(_E)]
- class EndoDiagram(relation, drawer)#
Bases:
Generic[_E]Draws endo diagrams.
Useful for visualizing endo-relations in Jupyter notebooks.
- Parameters:
relation (
EndoRelation[TypeVar(_E)]) β The endo relationdrawer (
EndoDiagramDrawer) β The drawer
- property relation: EndoRelation[_E]#
Get the relation.
- Returns:
The underlying relation
- Return type:
EndoRelation[_E]
- render(path)#
Render the diagram in a file.
- pipe(output='svg')#
Pipe the diagram.
- property digraph: Digraph#
Get the Graphviz Digraph for the diagram.
- Returns:
The Graphviz Digraph representing the diagram
- Return type:
Digraph
- class BinaryTable(relation, domain_renderer=None, co_domain_renderer=None)#
Bases:
Generic[_E,_F]Renders a binary relation as a table in Jupyter notebooks.
- Parameters:
relation (
BinaryRelation[TypeVar(_E),TypeVar(_F)]) β The binary relationdomain_renderer (
Optional[CellRenderer[TypeVar(_E),TypeVar(_F)]], default:None) β The domain rendererco_domain_renderer (
Optional[CellRenderer[TypeVar(_E),TypeVar(_F)]], default:None) β The codomain renderer
- property relation: BinaryRelation[_E, _F]#
Get the relation.
- Returns:
The underlying relation
- Return type:
BinaryRelation[_E, _F]
- property domain_renderer: CellRenderer[_E, _F]#
Get the domain renderer.
- Returns:
The domain renderer
- Return type:
CellRenderer[_E, _F]
- property co_domain_renderer: CellRenderer[_E, _F]#
Get the co-domain renderer.
- Returns:
The co-domain renderer
- Return type:
CellRenderer[_E, _F]