Visualization Utilities#
System Graph Visualizer#
Graphviz-based system graph visualization utilities.
- This module renders SysSimX systems as Graphviz directed graphs with:
grouped component clusters,
port-aware record labels,
event connections styled distinctly,
algebraic loop connections highlighted, and
optional unit labels on edges.
- syssimx.viz.system_graph_visualizer._auto_color_for_group(group_name, base_saturation=0.35, base_lightness=0.85)[source]#
Generate a deterministic pastel color for a group name.
- syssimx.viz.system_graph_visualizer._build_palette(system)[source]#
Build a group color palette for the system.
- syssimx.viz.system_graph_visualizer._is_event_port(port)[source]#
Return True if a port is an event-type port.
- syssimx.viz.system_graph_visualizer._format_port_label(port_name, color=None)[source]#
Format a port label with optional color emphasis.
- syssimx.viz.system_graph_visualizer._build_ports_column(port_names, event_ports, feedthrough_ports=None)[source]#
Build an HTML table cell for a port column.
- syssimx.viz.system_graph_visualizer._record_label_for_component(comp, execution_idx=-1)[source]#
Build an HTML-like record label for a component.
The label includes input and output port columns with explicit anchors. Output ports with direct feedthrough are highlighted in red; event ports are highlighted in blue.
- Parameters:
comp (CoSimComponent) – Component to render.
execution_idx (int) – Optional execution order index to display.
- Returns:
Graphviz HTML-like label string.
- Return type:
- syssimx.viz.system_graph_visualizer._edge_unit_label(system, conn)[source]#
Return unit label from the destination port specification.
- syssimx.viz.system_graph_visualizer._is_zero_delay_connection(system, conn, active_outputs)[source]#
Check if a connection participates in zero-delay direct feedthrough.
- Parameters:
- Returns:
True if this connection contributes to the zero-delay dependency graph.
- Return type:
- syssimx.viz.system_graph_visualizer._is_direct_feedthrough_output(comp, port_name)[source]#
Return True if the given output port is direct-feedthrough.
- Parameters:
comp (CoSimComponent) – Component to inspect.
port_name (str) – Output port name on the component.
- Returns:
True if the output port has direct-feedthrough dependencies.
- Return type:
- syssimx.viz.system_graph_visualizer._is_direct_feedthrough_input(comp, port_name)[source]#
Return True if the given input port feeds any direct-feedthrough output.
- Parameters:
comp (CoSimComponent) – Component to inspect.
port_name (str) – Input port name on the component.
- Returns:
True if the input port appears in any direct-feedthrough dependency list.
- Return type:
- syssimx.viz.system_graph_visualizer._build_loop_index(system)[source]#
Build a component-to-loop index mapping.
- syssimx.viz.system_graph_visualizer._legend_label()[source]#
Return the HTML label used for the legend node.
- Returns:
Graphviz HTML-like label string.
- Return type:
- class syssimx.viz.system_graph_visualizer.SystemGraphVisualizer[source]#
Bases:
objectRender a System as a Graphviz directed graph.
- __init__(system)[source]#
Initialize the visualizer.
- Parameters:
system (System) – System instance to visualize.
- visualize(filename='system_graph', format='svg')[source]#
Build and render a Graphviz system graph.
This method constructs a new Graphviz Digraph, adds component nodes, connection edges, and renders to disk without opening a viewer.
- save(filepath)[source]#
Save the current graph to a file.
- Parameters:
filepath (str) – Output path with extension (e.g., “graph.svg”).
- Raises:
RuntimeError – If visualize() was not called before saving.
- Return type:
None
- _add_ungrouped_components()[source]#
Add any components that were not placed in a group cluster.
- Return type:
None