ham_graph_to_ham_operator

ham_graph_to_ham_operator#

iqm.qaoa.transforming_functions.ham_graph_to_ham_operator(ham_graph)[source]#

A function to transform Hamiltonian represented as a Graph into a SparsePauliOp object.

A Hamiltonian as SparsePauliOp may be used by qiskit functions that e.g., calculate expectation values.

Parameters:

ham_graph (Graph) – A Graph whose nodes and edges have a parameter bias whose value corresponds to the coefficients before the corresponding Z and ZZ operators in the problem Hamiltonian.

Returns:

The Hamiltonian as SparsePauliOp to be used by qiskit.

Return type:

SparsePauliOp