graph_viewer.py#

Viewer graphs of a group’s model hierarchy and connections.

class openmdao.visualization.graph_viewer.GraphViewer(group)[source]

Bases: object

A class for viewing the model hierarchy and connections in a group.

Parameters:
group<Group>

The Group with graph to be viewed.

Attributes:
_group<Group>

The Group with graph to be viewed.

__init__(group)[source]

Initialize the GraphViewer.

Parameters:
group<Group>

The Group with graph to be viewed.

write_graph(gtype='dataflow', recurse=True, show_vars=False, display=True, show_boundary=False, exclude=(), outfile=None)[source]

Use pydot to create a graphical representation of the specified graph.

Parameters:
gtypestr

The type of graph to create. Options include ‘system’, ‘component’, ‘nested’, and ‘dataflow’.

recursebool

If True, recurse into subsystems when gtype is ‘dataflow’.

show_varsbool

If True, show all variables in the graph. Only relevant when gtype is ‘dataflow’.

displaybool

If True, pop up a window to view the graph.

show_boundarybool

If True, include connections to variables outside the boundary of the Group.

excludeiter of str

Iter of pathnames to exclude from the generated graph.

outfilestr or None

The name of the file to write the graph to. The format is inferred from the extension. Default is None, which writes to ‘<system_path>_<gtype>_graph.html’, where system_path is ‘model’ for the top level group, and any ‘.’ in the pathname is replaced with ‘_’.

Returns:
pydot.Dot or None

The pydot graph that was created.

openmdao.visualization.graph_viewer.write_graph(G, prog='dot', display=True, outfile='graph.html')[source]

Write the graph to a file and optionally display it.

Parameters:
Gnx.DiGraph or pydot.Dot

The graph to be written.

progstr

The graphviz program to use for layout.

displaybool

If True, display the graph after writing it.

outfilestr

The name of the file to write. Default is ‘graph.html’.

Returns:
pydot.Dot

The graph that was written.