def template_graph_coloring(filename, alpha, eps, steps, time, title=None, tolerance=0.1, threshold_steps=10): if (title is None): title = filename graph = read_graph(filename) network = hysteresisgcolor(graph.data, alpha, eps) output_dynamic = network.simulate(steps, time) draw_dynamics(output_dynamic.time, output_dynamic.output, x_title="Time", y_title="State") clusters = output_dynamic.allocate_clusters(tolerance, threshold_steps) for index in range(0, len(clusters)): print("Color #", index, ": ", clusters[index]) coloring_map = output_dynamic.allocate_map_coloring( tolerance, threshold_steps) draw_graph(graph, coloring_map)
def template_graph_coloring(filename, alpha, eps, steps, time, title = None, tolerance = 0.1): if (title is None): title = filename; graph = read_graph(filename); network = hysteresisgcolor(graph.data, alpha, eps); (t, dyn) = network.simulate(steps, time); draw_dynamics(t, dyn, x_title = "Time", y_title = "State"); clusters = network.get_clusters(tolerance); for index in range(0, len(clusters)): print("Color #", index, ": ", clusters[index]); coloring_map = network.get_map_coloring(tolerance); draw_graph(graph, coloring_map);
def template_graph_coloring(filename, alpha, eps, steps, time, title = None, tolerance = 0.1, threshold_steps = 10): if (title is None): title = filename; graph = read_graph(filename); network = hysteresisgcolor(graph.data, alpha, eps); output_dynamic = network.simulate(steps, time); draw_dynamics(output_dynamic.time, output_dynamic.output, x_title = "Time", y_title = "State"); clusters = output_dynamic.allocate_clusters(tolerance, threshold_steps); for index in range(0, len(clusters)): print("Color #", index, ": ", clusters[index]); coloring_map = output_dynamic.allocate_map_coloring(tolerance, threshold_steps); draw_graph(graph, coloring_map);
def templateTestColoring(self, filename, alpha, eps, steps, time): graph = read_graph(filename); network = hysteresisgcolor(graph.data, alpha, eps); (t, dyn) = network.simulate(steps, time); map_coloring = network.get_map_coloring(0.05); # Check number of colors assigned_colors = set(map_coloring); # Check validity of color numbers for color_number in range(0, len(assigned_colors), 1): assert color_number in assigned_colors; # Check validity of colors for index_node in range(len(graph.data)): color_neighbors = [ map_coloring[index] for index in range(len(graph.data[index_node])) if graph.data[index_node][index] != 0 and index_node != index]; #print(index_node, map_coloring[index_node], color_neighbors, assigned_colors, map_coloring, "\n\n"); assert map_coloring[index_node] not in color_neighbors;
def templateTestColoring(self, filename, alpha, eps, steps, time): graph = read_graph(filename); network = hysteresisgcolor(graph.data, alpha, eps); output_analyser = network.process(steps, time); map_coloring = output_analyser.allocate_map_coloring(0.05, 20); # Check number of colors assigned_colors = set(map_coloring); # Check validity of color numbers for color_number in range(0, len(assigned_colors), 1): assert color_number in assigned_colors; # Check validity of colors for index_node in range(len(graph.data)): color_neighbors = [ map_coloring[index] for index in range(len(graph.data[index_node])) if graph.data[index_node][index] != 0 and index_node != index]; #print(index_node, map_coloring[index_node], color_neighbors, assigned_colors, map_coloring, "\n\n"); assert map_coloring[index_node] not in color_neighbors;
def template_graph_coloring(filename, alpha, eps, steps, time, title=None, tolerance=0.1): if (title is None): title = filename graph = read_graph(filename) network = hysteresisgcolor(graph.data, alpha, eps) (t, dyn) = network.simulate(steps, time) draw_dynamics(t, dyn, x_title="Time", y_title="State") clusters = network.get_clusters(tolerance) for index in range(0, len(clusters)): print("Color #", index, ": ", clusters[index]) coloring_map = network.get_map_coloring(tolerance) draw_graph(graph, coloring_map)
def templateTestColoring(self, filename, alpha, eps, steps, time): graph = read_graph(filename) network = hysteresisgcolor(graph.data, alpha, eps) (t, dyn) = network.simulate(steps, time) map_coloring = network.get_map_coloring(0.05) # Check number of colors assigned_colors = set(map_coloring) # Check validity of color numbers for color_number in range(0, len(assigned_colors), 1): assert color_number in assigned_colors # Check validity of colors for index_node in range(len(graph.data)): color_neighbors = [ map_coloring[index] for index in range(len(graph.data[index_node])) if graph.data[index_node][index] != 0 and index_node != index ] #print(index_node, map_coloring[index_node], color_neighbors, assigned_colors, map_coloring, "\n\n"); assert map_coloring[index_node] not in color_neighbors