paroto.viz.mermaid#
Mermaid diagram generators for optimization problem visualization.
This module provides utilities to create Mermaid graph diagrams showing relationships between parameters, models, and constraints, with support for hierarchical parameter visualization.
Diagram Conventions#
Parameters (all levels): Green circles ((symbol)) - #90EE90
Models: Blue rectangles [name] - #87CEEB
Constraints: Pink diamonds {equation} - #FFB6C1
Subgraphs: Transparent background (fill:none, stroke:none)
Node labels: Simplified to core symbol/name only
Hierarchy: Shown by left-to-right position, not by color/shape variation
Attributes#
Functions#
|
Get parameter symbol or simple label. |
|
Get Mermaid color for a hierarchy level. |
|
Get Mermaid node definition string. |
|
Generate a simple Mermaid flowchart showing system connectivity. |
|
Generate hierarchical Mermaid diagram showing parameter dependencies. |
|
Generate simplified hierarchical diagram with subsystem-level abstraction. |
Module Contents#
- paroto.viz.mermaid.get_param_label(node_name)#
Get parameter symbol or simple label.
- paroto.viz.mermaid.LEVEL_COLORS#
- paroto.viz.mermaid.PARAM_SYMBOLS#
- paroto.viz.mermaid.MERMAID_SHAPES#
- paroto.viz.mermaid.get_level_color(level, nodes_at_level, max_level)#
Get Mermaid color for a hierarchy level.
- Parameters:
- Returns:
Hex color code
- Return type:
Notes
Level 0: Green (primary parameters)
Levels with constraints: Pink
Other levels: Yellow gradient
- paroto.viz.mermaid.get_mermaid_node_def(node_id, label, node_type)#
Get Mermaid node definition string.
- paroto.viz.mermaid.generate_simple_graph(graph, output_path)#
Generate a simple Mermaid flowchart showing system connectivity.
Creates a graph with three layers: parameters (inputs), models (processing), and constraints (outputs/checks). Automatically extracts nodes from the ProblemGraph.
- paroto.viz.mermaid.generate_hierarchical_graph(graph, output_path, max_level=None, orientation='LR')#
Generate hierarchical Mermaid diagram showing parameter dependencies.
Creates a layered graph where nodes are organized by hierarchy level, showing actual connections between parameters, models, and constraints.
- Parameters:
graph (
ProblemGraph) – Problem graph from extract_hierarchy()output_path (
str) – File path where the Mermaid diagram will be savedmax_level (
int, optional) – Maximum hierarchy level to display. If None, shows all levelsorientation (
str, optional) – Graph orientation: “LR” (left-right) or “TD” (top-down). Default: “LR”
- Returns:
The output file path where the diagram was saved
- Return type:
- paroto.viz.mermaid.generate_simplified_hierarchical_graph(graph, output_path, orientation='LR')#
Generate simplified hierarchical diagram with subsystem-level abstraction.
Similar to generate_hierarchical_graph but groups variables by subsystem for a cleaner, higher-level view.
- Parameters:
- Returns:
The output file path where the diagram was saved
- Return type: