qiskit_addon_opt_mapper.applications.Clique¶
- class Clique(graph, size=None)[source]¶
Bases:
GraphOptimizationApplicationOptimization application for the “clique” [1] problem based on a NetworkX graph.
References
[1]: “Clique (graph theory)”, https://en.wikipedia.org/wiki/Clique_(graph_theory)
Init method.
- 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.
size (int | None) – The size of the clique. When it’s None, the default, this class makes an optimization model for a maximal clique instead of the specified size of a clique.
- __init__(graph, size=None)[source]¶
Init method.
- 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.
size (int | None) – The size of the clique. When it’s None, the default, this class makes an optimization model for a maximal clique instead of the specified size of a clique.
- Return type:
None
Methods
__init__(graph[, size])Init method.
draw([result, pos])Draw a graph with the result.
interpret(result)Interpret a result as a list of node indices.
sample_most_likely(state_vector)Compute the most likely binary string from state vector.
Represent as an optimization problem.
Attributes
- draw(result=None, pos=None)[source]¶
Draw a graph with the result.
When the result is None, draw an original graph without colors.
- property nx_graph: Graph¶
Getter of the graph in Networkx format.
- Returns:
A graph for a problem
- static sample_most_likely(state_vector)[source]¶
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:
- property size: int | None¶
Getter of size.
- Returns:
The size of the clique, None when maximal clique
- to_optimization_problem()[source]¶
Represent as an optimization problem.
Convert a clique problem instance into a
OptimizationProblem. When “size” is None, this makes an optimization model for a maximal clique instead of the specified size of a clique.- Returns:
The
OptimizationProblemcreated from the clique problem instance.- Return type:
OptimizationProblem