def helper_kruskals_plugin(): global g, g_mat, order_val, full_mat, count count = 0 start = time.time() obj_sw = SashaWang() obj_sw.store(g, order_val) oracle_plugin = obj_sw p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() end = time.time() print('COUNT Sasha Wang', count, end - start, "\n\n") start = time.time() count = 0 obj = unified_graph_lb_ub() obj.store(g, order_val) oracle_plugin = obj p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() end = time.time() print("COUNT LBTree enabled", count, end - start, "\n\n") start = time.time() count = 0 obj = ParamTriSearch(2, obj_sw.ub_matrix) obj.store(g, order_val) oracle_plugin = obj p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() end = time.time() print("PARA", count, end - start, "\n\n")
def kruskals_TSS(pr, measure, kind, order_val, timer, algo): """ Jees added this part to test the naive code for intersection-TriSearch(This) This accepts a graph(graph with edge and distance format) and converts it into adjacency list representation and stores it This updates a new edge the moment its gets a new resolution This computes the value of lower-bound only when needed by a query Q(a, b) This find the Triangles through intersection of adjacency list of both end points of the query edge (a & b) The class IntersectTriSearch: is initialized with the graph and it takes care of everything else including conversion to adjacency list. """ print("Experiment Starting TSS (Kruskals)\n") global full_mat, count g = {} timer.start() oracle_plugin = IntersectTriSearch({}, order_val) p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() print( "KRUSKAL - IntersctionTriSearch Experiments:\nActual(Vanila) KRUSKAL Path Length: {}\nIntersctionTriSearch(our plugin) Prims Path Length: {}\nmeasure: {}, kind: {}, order_val: {}". format(pr.mst_path_length, p.mst_path_length, measure, kind, order_val)) print("COUNT intersct Trisearch: {}\nLB Time(Tri): {}\nUB Time(Tri): {}\n\n".format(count, timer.time_elapsed - oracle_plugin.sp_time, oracle_plugin.sp_time)) print("My Lookup count(Tri): {}".format(oracle_plugin.lookup_count))
def kruskals_DSS(pr, measure, kind, order_val, timer, algo): """ DSS Solution Scheme """ print("Experiment Starting DSS (Kruskals)\n") global full_mat, count g = {} timer.start() obj_dss = DSS(g, order_val) oracle_plugin = obj_dss p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() assert abs(p.mst_path_length - pr.mst_path_length) < 0.000001 print( "Plugin with DSS\nActual(SW) {} Path Length: {}\nDSS Path Length: {}\n" "measure: {}, kind: {}, order_val: {}".format(algo, p.mst_path_length, pr.mst_path_length, measure, kind, order_val)) print("DSS COUNT {}\nTime: {}\n\n".format( count, timer.time_elapsed, ))
def kruskals_LSS(pr, measure, kind, order_val, timer, algo): """ code to test the landmark based methods """ print("Experiment Starting LSS (Kruskals)\n") global full_mat, count g = {} timer.start() oracle_plugin = LSS(g, order_val, 6, oracle) p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() print("{} COUNT LSS: {}\nTime(LSS): {}\n\n".format(algo, count, timer.time_elapsed))
def kruskals_SW(pr, measure, kind, order_val, timer, algo): print("Experiment Starting SW (Kruskals)\n") global full_mat, count g = {} timer.start() obj_sw = SashaWang() obj_sw.store(g, order_val) oracle_plugin = obj_sw p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() print("(KRUSKAL)Sasha Wang - Original Length: {}, our lenght: {}, measure: {}, kind: {}, order_val: {}". format(pr.mst_path_length, p.mst_path_length, measure, kind, order_val)) assert abs(p.mst_path_length - pr.mst_path_length) < 0.000001 sasha_wang_results = "COUNT Sasha Wang " + str(count) + " Time " + str( timer.time_elapsed - obj_sw.update_time) + "\n" print("COUNT Sasha Wang: {}, Time(total): {}, Time(SP): {}\n\n".format(count, timer.time_elapsed, obj_sw.update_time))
def helper_kruskals_plugin(g, full_mat1, g_mat, measure, kind, order_val, algo, three=False): global full_mat, count g, full_mat, g_mat = g, full_mat1, g_mat timer = Timer() pr = vanila_kruskals(order_val, time_waste_oracle) timer.start() pr.mst() timer.end() base_algo_results = "COUNT Without Plugin " + str(count) + " Time " + str( timer.time_elapsed) + "\n" print("COUNT Without Plugin ", count, timer.time_elapsed, "\n\n") timer.start() obj_sw = SashaWang() obj_sw.store(g, order_val) oracle_plugin = obj_sw p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() print( "(KRUSKAL)Sasha Wang - Original Length: {}, our lenght: {}, measure: {}, kind: {}, order_val: {}" .format(pr.mst_path_length, p.mst_path_length, measure, kind, order_val)) assert abs(p.mst_path_length - pr.mst_path_length) < 0.000001 sasha_wang_results = "COUNT Sasha Wang " + str(count) + " Time " + str( timer.time_elapsed - obj_sw.update_time) + "\n" print("COUNT Sasha Wang ", count, timer.time_elapsed - obj_sw.update_time, "\n\n") """ DSS Solution Scheme """ g = {} timer.start() obj_dss = DSS(g, order_val) oracle_plugin = obj_dss p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() assert abs(p.mst_path_length - pr.mst_path_length) < 0.000001 print( "Plugin with DSS\nActual(SW) {} Path Length: {}\nDSS Path Length: {}\n" "measure: {}, kind: {}, order_val: {}".format(algo, p.mst_path_length, pr.mst_path_length, measure, kind, order_val)) print("DSS COUNT {}\nTime: {}\n\n".format( count, timer.time_elapsed, )) """ Jees added this part to test the naive code for intersection-TriSearch(This) This accepts a graph(graph with edge and distance format) and converts it into adjacency list representation and stores it This updates a new edge the moment its gets a new resolution This computes the value of lower-bound only when needed by a query Q(a, b) This find the Triangles through intersection of adjacency list of both end points of the query edge (a & b) The class IntersectTriSearch: is initialized with the graph and it takes care of everything else including conversion to adjacency list. """ timer.start() oracle_plugin = IntersectTriSearch({}, order_val) p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() print( "KRUSKAL - IntersctionTriSearch Experiments:\nActual(Vanila) KRUSKAL Path Length: {}\nIntersctionTriSearch(our plugin) Prims Path Length: {}\nmeasure: {}, kind: {}, order_val: {}" .format(pr.mst_path_length, p.mst_path_length, measure, kind, order_val)) print( "COUNT intersct Trisearch: {}\nLB Time(Tri): {}\nUB Time(Tri): {}\n\n". format(count, timer.time_elapsed - oracle_plugin.sp_time, oracle_plugin.sp_time)) print("My Lookup count(Tri): {}".format(oracle_plugin.lookup_count)) """ code to test the landmarkbased methods """ timer.start() oracle_plugin = LSS({}, order_val, 6, oracle) p = kruskals_plugin(order_val, oracle, oracle_plugin) p.mst() timer.end() print("{} COUNT LSS: {}\nTime(LSS): {}\n\n".format(algo, count, timer.time_elapsed)) """