finesse.model.Model.component_tree

Model.component_tree(root: finesse.element.ModelElement | str | None = None, network_type: str | finesse.utilities.network_filter.NetworkType = NetworkType.COMPONENT, show_detectors: bool = False, show_ports: bool = False, radius: int | None = None, directed: bool = False) TreeNode[source]

Retrieves a tree containing the network representing the components connected to the specified root. See also Visualizing the model.

Parameters
rootstr | ModelElement | Node | None, optional

Root element/node to start drawing the tree from. Is also used in combination with radius, for distance based filtering, by default None. When network_type is components, None will default to the first finesse.components.laser.Laser found in the model.

network_typestr | NetworkType, optional

Which network to plot, can be one of ‘optical’, ‘component’, ‘full’, by default NetworkType.COMPONENT

show_detectorsbool, optional

Whether to add detectors to the graph, by default False

show_portsbool, optional

Whether to show by which ports components are connected, by default False

radiusint >= 1 | None, optional

Must be used in combination with root, only include nodes of the network that are radius or less edges away from the root node, by default None, meaning that no nodes are filtered out.

directedbool, optional

Whether to use directed distance-based filtering, by default False. If set to True, will only include outgoing edges from the root node. See also the undirected argument of networkx.generators.ego.ego_graph()

Returns
TreeNode

The root tree node, with connected components as branches.

Raises
ValueError

If the specified root is not a model element.

Notes

Uses networkx.generators.ego.ego_graph() for the distance-based filtering.