finam_graph.GraphDiagram#
- class finam_graph.GraphDiagram(sizes=<finam_graph.diagram.GraphSizes object>, colors=<finam_graph.diagram.GraphColors object>, corner_radius=5, max_label_length=12, max_slot_label_length=6)[source]#
Bases:
object
Diagram drawer.
Examples
composition = Composition([comp_a, comp_b]) composition.initialize() comp_a.outputs["Out"] >> comp_b.inputs["In"] diagram = GraphDiagram() diagram.draw(composition, save_path="graph.svg")
- Parameters:
sizes (GraphSizes) – Graph sizing properties object
GraphSizes
.colors (GraphColors) – Graph coloring properties object
GraphColors
.corner_radius (int) – Radius for rounded corners
max_label_length (int) – Maximum number of characters in component and adapter labels
max_slot_label_length (int) – Maximum number of characters in input and output slot labels
Methods
draw
(composition[, details, excluded, ...])Draw a graph diagram.
- draw(composition, details=2, excluded=None, positions=None, labels=None, colors=None, show=True, block=True, save_path=None, max_iterations=25000, seed=None)[source]#
Draw a graph diagram.
- Parameters:
composition (Composition) – The
finam.Composition
to draw a graph diagram forexcluded (list or set, optional) – List of excluded components. Default: None
details (int, optional) – Level of details of the graph plot.
0: Simple graph without slots and adapters
1: Detailed graph, with collapsed adapters
2: Full detailed graph, with adapters
Defaults to 2.
positions (dict, optional) – Dictionary of grid cell position tuples per component/adapter. Default: None (optimized)
labels (dict, optional) – Dictionary of label overrides for components, adapters and input/output slots. Default: None
colors (dict, optional) – Dictionary of component/adapter color overrides. Default: None
show (bool, optional) – Whether to show the diagram. Default: True
block (bool, optional) – Should the diagram be shown in blocking mode? Default: True
save_path (pathlike, optional) – Path to save image file. Default: None (i.e. don’t save)
max_iterations (int, optional) – Maximum iterations for optimizing node placement. Default: 25000
seed (int, optional) – Random seed for the optimizer. Default: None