qiskit-documentation/docs/api/qiskit/0.24/qiskit.optimization.applica...

80 lines
4.0 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: vertex_cover
description: API reference for qiskit.optimization.applications.ising.vertex_cover
in_page_toc_min_heading_level: 2
python_api_type: module
python_api_name: qiskit.optimization.applications.ising.vertex_cover
---
<span id="module-qiskit.optimization.applications.ising.vertex_cover" />
<span id="qiskit-optimization-applications-ising-vertex-cover" />
# qiskit.optimization.applications.ising.vertex\_cover
Convert vertex cover instances into Pauli list Deal with Gset format. See [https://web.stanford.edu/\~yyye/yyye/Gset/](https://web.stanford.edu/~yyye/yyye/Gset/)
**Functions**
| | |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| [`check_full_edge_coverage`](#qiskit.optimization.applications.ising.vertex_cover.check_full_edge_coverage "qiskit.optimization.applications.ising.vertex_cover.check_full_edge_coverage")(x, w) | **param x**binary string as numpy array. |
| [`get_graph_solution`](#qiskit.optimization.applications.ising.vertex_cover.get_graph_solution "qiskit.optimization.applications.ising.vertex_cover.get_graph_solution")(x) | Get graph solution from binary string. |
| [`get_operator`](#qiskit.optimization.applications.ising.vertex_cover.get_operator "qiskit.optimization.applications.ising.vertex_cover.get_operator")(weight\_matrix) | Generate Hamiltonian for the vertex cover :param weight\_matrix: adjacency matrix. |
### check\_full\_edge\_coverage
<Function id="qiskit.optimization.applications.ising.vertex_cover.check_full_edge_coverage" github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.8/qiskit/optimization/applications/ising/vertex_cover.py" signature="check_full_edge_coverage(x, w)">
**Parameters**
* **x** (*numpy.ndarray*) binary string as numpy array.
* **w** (*numpy.ndarray*) adjacency matrix.
**Returns**
value of the cut.
**Return type**
float
</Function>
### get\_graph\_solution
<Function id="qiskit.optimization.applications.ising.vertex_cover.get_graph_solution" github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.8/qiskit/optimization/applications/ising/vertex_cover.py" signature="get_graph_solution(x)">
Get graph solution from binary string.
**Parameters**
**x** (*numpy.ndarray*) binary string as numpy array.
**Returns**
graph solution as binary numpy array.
**Return type**
numpy.ndarray
</Function>
### get\_operator
<Function id="qiskit.optimization.applications.ising.vertex_cover.get_operator" github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.8/qiskit/optimization/applications/ising/vertex_cover.py" signature="get_operator(weight_matrix)">
Generate Hamiltonian for the vertex cover :param weight\_matrix: adjacency matrix. :type weight\_matrix: numpy.ndarray
**Returns**
operator for the Hamiltonian and a constant shift for the obj function.
**Return type**
tuple([WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator"), float)
Goals: 1 color some vertices as red such that every edge is connected to some red vertex 2 minimize the vertices to be colored as red
Hamiltonian: H = A \* H\_A + H\_B H\_A = sum\_\{(i,j)in E}\{(1-Xi)(1-Xj)} H\_B = sum\_\{i}\{Zi}
H\_A is to achieve goal 1 while H\_b is to achieve goal 2. H\_A is hard constraint so we place a huge penality on it. A=5. Note Xi = (Zi+1)/2
</Function>