|
pyclustering
0.10.1
pyclustring is a Python, C++ data mining library.
|
3 @brief Graph coloring algorithm based on Sync Oscillatory Network
4 @details Implementation based on paper @cite article::gcolor::sync::1.
6 @authors Andrei Novikov (pyclustering@yandex.ru)
8 @copyright BSD-3-Clause
19 @brief Analyser of output dynamic of the oscillatory network syncgcolor.
23 def __init__(self, phase, time, pointer_sync_analyser):
25 @brief Constructor of the analyser.
27 @param[in] phase (list): Output dynamic of the oscillatory network, where one iteration consists of all phases of oscillators.
28 @param[in] time (list): Simulation time.
29 @param[in] pointer_sync_analyser (POINTER): Pointer to CCORE analyser, if specified then other arguments can be omitted.
33 super().
__init__(phase, time, pointer_sync_analyser);
38 @brief Allocates clusters, when one cluster defines only one color.
40 @param[in] tolerance (double): Defines maximum deviation between phases.
42 @return (list) Clusters [vertices with color 1], [vertices with color 2], ..., [vertices with color n].
51 @brief Allocates coloring map for graph that has been processed.
53 @param[in] tolerance (double): Defines maximum deviation between phases.
55 @return (list) Colors for each node (index of node in graph), for example [color1, color2, color2, ...].
60 number_oscillators = len(self.
_dynamic[0]);
62 coloring_map = [0] * number_oscillators;
64 for color_index
in range(len(clusters)):
65 for node_index
in clusters[color_index]:
66 coloring_map[node_index] = color_index;
73 @brief Oscillatory network based on Kuramoto model with negative and positive connections for graph coloring problem.
77 def __init__(self, graph_matrix, positive_weight, negative_weight, reduction = None):
79 @brief Constructor of the oscillatory network syncgcolor for graph coloring problem.
81 @param[in] graph_matrix (list): Graph represented by matrix.
82 @param[in] positive_weight (double): Value of weight of positive connections.
83 @param[in] negative_weight (double): Value of weight of negative connections.
84 @param[in] reduction (bool): Inverse degree of the processed graph.
87 number_oscillators = len(graph_matrix);
88 super().
__init__(number_oscillators, type_conn = conn_type.DYNAMIC, ccore =
False);
90 if (reduction ==
None):
101 def _create_connections(self, graph_matrix):
103 @brief Creates connection in the network in line with graph.
105 @param[in] graph_matrix (list): Matrix representation of the graph.
109 for row
in range(0, len(graph_matrix)):
110 for column
in range (0, len(graph_matrix[row])):
111 if (graph_matrix[row][column] > 0):
115 def _phase_kuramoto(self, teta, t, argv):
117 @brief Returns result of phase calculation for oscillator in the network.
119 @param[in] teta (double): Value of phase of the oscillator with index argv in the network.
120 @param[in] t (double): Unused, can be ignored.
121 @param[in] argv (uint): Index of the oscillator in the network.
123 @return (double) New value of phase for oscillator with index argv.
139 def process(self, order = 0.998, solution = solve_type.FAST, collect_dynamic = False):
141 @brief Performs simulation of the network (performs solving of graph coloring problem).
143 @param[in] order (double): Defines when process of synchronization in the network is over, range from 0 to 1.
144 @param[in] solution (solve_type): defines type (method) of solving diff. equation.
145 @param[in] collect_dynamic (bool): If True - return full dynamic of the network, otherwise - last state of phases.
147 @return (syncnet_analyser) Returns analyser of results of coloring.
Represents output dynamic of Sync.
Neural Network: Oscillatory Neural Network based on Kuramoto model.
def simulate_dynamic(self, order=0.998, solution=solve_type.FAST, collect_dynamic=False, step=0.1, int_step=0.01, threshold_changes=0.0000001)
Performs dynamic simulation of the network until stop condition is not reached.
Analyser of output dynamic of the oscillatory network syncgcolor.
Model of oscillatory network that is based on the Kuramoto model of synchronization.
def __init__(self, graph_matrix, positive_weight, negative_weight, reduction=None)
Constructor of the oscillatory network syncgcolor for graph coloring problem.
def process(self, order=0.998, solution=solve_type.FAST, collect_dynamic=False)
Performs simulation of the network (performs solving of graph coloring problem).
def __init__(self, phase, time, pointer_sync_analyser)
Constructor of the analyser.
def has_connection(self, i, j)
Returns True if there is connection between i and j oscillators and False - if connection doesn't exi...
Oscillatory network based on Kuramoto model with negative and positive connections for graph coloring...
def set_connection(self, i, j)
Couples two specified oscillators in the network with dynamic connections.
def _create_connections(self, graph_matrix)
Creates connection in the network in line with graph.
Neural and oscillatory network module. Consists of models of bio-inspired networks.
def allocate_sync_ensembles(self, tolerance=0.01, indexes=None, iteration=None)
Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble c...
def allocate_map_coloring(self, tolerance=0.1)
Allocates coloring map for graph that has been processed.
def allocate_color_clusters(self, tolerance=0.1)
Allocates clusters, when one cluster defines only one color.