def test_grow_shrink(self): print("Plotting Test Start:\tGrow & Shrink (GC)") start_time = time.time() name = "grow_shrink" graph = Graph() graphs = [] # create graphs collection instance gc = GraphCollection(name) graph.add_vertex(7) # SCC graph.add_edge(graph.vertex(0),graph.vertex(1)) graph.add_edge(graph.vertex(1),graph.vertex(2)) graph.add_edge(graph.vertex(2),graph.vertex(3)) graph.add_edge(graph.vertex(3),graph.vertex(4)) graph.add_edge(graph.vertex(4),graph.vertex(5)) graph.add_edge(graph.vertex(5),graph.vertex(6)) graph.add_edge(graph.vertex(6),graph.vertex(0)) gc.append(copy.deepcopy(graph)) in_edges = [] out_edges = [] scc_edges = [] print("Growing IN") for x in range (7, 27): new_vertex = graph.add_vertex() in_edge = graph.add_edge(new_vertex, graph.vertex(1)) in_edges.append(in_edge) gc.append(copy.deepcopy(graph)) print("Growing OUT") for x in range (27, 47): new_vertex = graph.add_vertex() out_edge = graph.add_edge(graph.vertex(2), new_vertex) out_edges.append(out_edge) gc.append(copy.deepcopy(graph)) print("Growing SCC") for x in range (7, 27): scc_edge = graph.add_edge(graph.vertex(1), graph.vertex(x)) scc_edges.append(scc_edge) gc.append(copy.deepcopy(graph)) scc_edge = graph.add_edge(graph.vertex(20+x), graph.vertex(2)) scc_edges.append(scc_edge) gc.append(copy.deepcopy(graph)) print("Shrinking SCC") for edge in scc_edges: graph.remove_edge(edge) gc.append(copy.deepcopy(graph)) print("Shrinking OUT") for edge in out_edges: graph.remove_edge(edge) gc.append(copy.deepcopy(graph)) print("Shrinking IN") for edge in in_edges: graph.remove_edge(edge) gc.append(copy.deepcopy(graph)) graphs.append(gc) print("Plotting Graphs") self.plot_graph_collection(graphs, name) duration = (time.time() - start_time) print("Plotting Test End:\tGrow & Shrink (deep copy)\t(%.2fs)\n" % duration)