Clique#

class Clique(graph, size=None)[ソース]#

ベースクラス: GraphOptimizationApplication

Optimization application for the 「clique」 [1] problem based on a NetworkX graph.

参照

[1]: 「Clique (graph theory)」, https://en.wikipedia.org/wiki/Clique_(graph_theory)

パラメータ:
  • 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.

Attributes

graph#

Getter of the graph

戻り値:

A graph for a problem

size#

Getter of size

戻り値:

The size of the clique, None when maximal clique

Methods

draw(result=None, pos=None)#

Draw a graph with the result. When the result is None, draw an original graph without colors.

パラメータ:
interpret(result)[ソース]#

Interpret a result as a list of node indices

パラメータ:

result (OptimizationResult | ndarray) – The calculated result of the problem

戻り値:

The list of node indices whose corresponding variable is 1

戻り値の型:

List[int]

static sample_most_likely(state_vector)#

Compute the most likely binary string from state vector.

パラメータ:

state_vector (QuasiDistribution | Statevector | ndarray | Dict) – state vector or counts or quasi-probabilities.

戻り値:

binary string as numpy.ndarray of ints.

例外:

ValueError – if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.

戻り値の型:

ndarray

to_quadratic_program()[ソース]#

Convert a clique problem instance into a QuadraticProgram. When 「size」 is None, this makes an optimization model for a maximal clique instead of the specified size of a clique.

戻り値:

The QuadraticProgram created from the clique problem instance.

戻り値の型:

QuadraticProgram