---
title: plot_graph (latest version)
description: API reference for samplomatic.visualization.plot_graph in the latest version of samplomatic
source: https://quantum.cloud.ibm.com/docs/en/api/samplomatic/auto/visualization-plot-graph
---

# plot\_graph

`samplomatic.visualization.plot_graph(graph: PyDiGraph[T, S], cols: int = 2, subgraph_idxs: None | int | Sequence[int] = None, layout_method: Literal['auto', 'spring', 'graphviz', 'graphviz_curved', 'graphviz_line'] | LayoutMethod[T, S] = 'auto', ranker: NodeRanker[T] | None = None) → Figure`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/visualization/plot_graph.py#L77-L254)

Visualize the disconnected subgraphs of a graph.

This function identifies all disconnected subgraphs within the given `graph` using the `weakly_connected_components()` method. Then, it plots all of the subgraphs corresponding to the indices specified in `subgraph_idxs`, with each selected subgraph displayed in its own subplot.

**Parameters**

- **graph** – The graph to visualize.
- **cols** – The number of columns in the returned figure.
- **subgraph\_idxs** – The indices of the connected subgraphs to include in the plot, or `None` to include all of the available subgraphs.
- **layout\_method** – A predefined layout method by name, or a callable implementing a layout.
- **ranker** – Specifies a node ranking that can be used by layout methods that group nodes topologically.

**Returns**

A Plotly graph.
