max_cut.base_maxcut
Base for MaxCut solvers.
Module Contents
Classes
Base for Maxcut Solver to validate inputs. |
- class max_cut.base_maxcut.BaseMaxCut
Bases:
noisecut.tree_structured.base.BaseBase for Maxcut Solver to validate inputs.
- n_vertices
Number of vertices of the graph.
- Type:
int
- size_w
Size of weight array.
- Type:
int
- weight
Weight of edge between each two vertices (see Notes).
- Type:
ndarray of float of shape (size_w,)
Notes
The weight is stored for a simple example when `n_vertices`=4 as below:
- weight[index of array] = w_2d[node_A][node_B]
Index of 1D array:(node A, node B) -> 0:(0,1), 1:(0,2), 2:(0,3), 3:(1,2), 4:(1,3), 5:(2,3)
- Index of arrayint
node_A * {2 * n_vertices - 3 - node_A} // 2 + node_B - 1
- validate_n(n: Any) bool
Validate number of vertices n.
- Parameters:
n (int) – Number of vertices.
- Returns:
True if n is a valid input.
- Return type:
bool
- validate_n_w_1d(w: Any, n: Any) bool
Validate number of vertices and weight array.
- Parameters:
w ({array-like, ndarray, dataframe} of shape (size_w,)) – 1D array weight data, see Notes.
n (int) – Number of vertices.
- Returns:
True if w and ‘n’ are valid inputs.
- Return type:
bool
Notes
When n_vertices=4, the weight data can be stored in two different formats:
2D array : w_2d[node A][node B] 1D array : w_1d[index of array] = w_2d[node_A][node_B]
Index of 1D array:(node A, node B) -> 0:(0,1), 1:(0,2), 2:(0,3), 3:(1,2), 4:(1,3), 5:(2,3)
- Index of arrayint
node_A * {2 * n_vertices - 3 - node_A} // 2 + node_B - 1
- validate_n_w_2d(w: Any, n: Any) bool
Validate number of vertices and weight array.
- Parameters:
w ({array-like, ndarray, dataframe} of shape (n_vertices, n_vertices)) – 2D array weight data, see Notes.
n (int) – Number of vertices.
- Returns:
True if w and ‘n’ are valid inputs.
- Return type:
bool
Notes
When n_vertices=4, the weight data can be stored in two different formats:
2D array : w_2d[node A][node B] 1D array : w_1d[index of array] = w_2d[node_A][node_B]
Index of 1D array:(node A, node B) -> 0:(0,1), 1:(0,2), 2:(0,3), 3:(1,2), 4:(1,3), 5:(2,3)
- Index of arrayint
node_A * {2 * n_vertices - 3 - node_A} // 2 + node_B - 1