qward.metrics.structural_metrics.StructuralMetrics

class StructuralMetrics(circuit)[source]

Extract structural metrics from QuantumCircuit objects.

This class analyzes the structural organization of a quantum circuit and computes metrics that describe its shape, topology, and logical arrangement. Structural metrics include circuit depth, width, size, density, connectivity, and software-engineering-inspired metrics such as LOC and Halstead adapted to quantum circuit representations.

circuit

The quantum circuit to analyze (inherited from MetricCalculator).

Type:

QuantumCircuit

_circuit_dag

DAG representation of the circuit, used to compute depth, connectivity, structural relationships, and topological features.

Type:

DAGCircuit | None

Initialize the StructuralMetrics calculator.

Parameters:

circuit (QuantumCircuit) – The quantum circuit to analyze

__init__(circuit)[source]

Initialize the StructuralMetrics calculator.

Parameters:

circuit (QuantumCircuit) – The quantum circuit to analyze

Methods

__init__(circuit)

Initialize the StructuralMetrics calculator.

get_metrics()

Calculate and return structural metrics combining LOC, Halstead, and circuit structure.

is_ready()

Check if the metric is ready to be calculated.

Attributes

circuit

Get the quantum circuit.

id

Get the ID of the metric.

metric_type

Get the type of this metric.

name

Get the name of the metric.