Maxcut#

class Maxcut(graph)[fuente]#

Bases: GraphOptimizationApplication

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

Referencias

[1]: «Maximum cut», https://en.wikipedia.org/wiki/Maximum_cut

Parámetros:

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

Devuelve:

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.

Parámetros:
static get_gset_result(x)[fuente]#

Get graph solution in Gset format from binary string.

Parámetros:

x (ndarray) – binary string as numpy array.

Devuelve:

A graph solution in Gset format.

Tipo del valor devuelto:

Dict[int, int]

interpret(result)[fuente]#

Interpret a result as two lists of node indices

Parámetros:

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

Devuelve:

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

Tipo del valor devuelto:

List[List[int]]

static parse_gset_format(filename)[fuente]#

Read graph in Gset format from file.

Parámetros:

filename (str) – the name of the file.

Devuelve:

An adjacency matrix as a 2D numpy array.

Tipo del valor devuelto:

ndarray

static sample_most_likely(state_vector)#

Compute the most likely binary string from state vector.

Parámetros:

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

Devuelve:

binary string as numpy.ndarray of ints.

Muestra:

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

Tipo del valor devuelto:

ndarray

to_quadratic_program()[fuente]#

Convert a Max-cut problem instance into a QuadraticProgram

Devuelve:

The QuadraticProgram created from the Max-cut problem instance.

Tipo del valor devuelto:

QuadraticProgram