Maxcut#

class Maxcut(graph)[ソース]#

ベースクラス: GraphOptimizationApplication

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

参照

[1]: 「Maximum cut」, https://en.wikipedia.org/wiki/Maximum_cut

パラメータ:

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

戻り値:

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.

パラメータ:
static get_gset_result(x)[ソース]#

Get graph solution in Gset format from binary string.

パラメータ:

x (ndarray) – binary string as numpy array.

戻り値:

A graph solution in Gset format.

戻り値の型:

Dict[int, int]

interpret(result)[ソース]#

Interpret a result as two lists of node indices

パラメータ:

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

戻り値:

Two lists of node indices correspond to two node sets for the Max-cut

戻り値の型:

List[List[int]]

static parse_gset_format(filename)[ソース]#

Read graph in Gset format from file.

パラメータ:

filename (str) – the name of the file.

戻り値:

An adjacency matrix as a 2D numpy array.

戻り値の型:

ndarray

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 Max-cut problem instance into a QuadraticProgram

戻り値:

The QuadraticProgram created from the Max-cut problem instance.

戻り値の型:

QuadraticProgram