VertexCover#
- class VertexCover(graph)[source]#
Bases:
GraphOptimizationApplication
Optimization application for the “vertex cover” [1] problem based on a NetworkX graph.
References
[1]: “Vertex cover”, https://en.wikipedia.org/wiki/Vertex_cover
- Parameters:
graph (Graph | ndarray | List) – A graph representing a problem. It can be specified directly as a NetworkX graph, or as an array or list format suitable to build out a NetworkX graph.
Attributes
- graph#
Getter of the graph
- Returns:
A graph for a problem
Methods
- draw(result=None, pos=None)#
Draw a graph with the result. When the result is None, draw an original graph without colors.
- Parameters:
result (OptimizationResult | ndarray | None) – The calculated result for the problem
- interpret(result)[source]#
Interpret a result as a list of node indices
- Parameters:
result (OptimizationResult | ndarray) – The calculated result of the problem
- Returns:
A list of node indices whose corresponding variable is 1
- Return type:
- static sample_most_likely(state_vector)#
Compute the most likely binary string from state vector.
- Parameters:
state_vector (QuasiDistribution | Statevector | ndarray | Dict) – state vector or counts or quasi-probabilities.
- Returns:
binary string as numpy.ndarray of ints.
- Raises:
ValueError – if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.
- Return type: