def get_meta_graph_stat(g): return MetaGraphStat(g, KWs) trees = pkl.load(open('tmp/binary_rooted_tree_samples.pkl')) U = 0.5 names = [# 'lst(round)', 'lst(ceil)', 'lst(floor)', # 'greedy' ] funcs = [lambda g, r, U, func=func: lst_dag(g, r, U, fixed_point_func=func, debug=False, edge_weight_decimal_point=2) for func in (# round, ceil, floor)] # funcs.append(greedy_grow) # t = trees[5] # from lst import round_edge_weights_by_multiplying # g_ceil, U = round_edge_weights_by_multiplying(t, U, 2, fixed_point_func=ceil) # g_floor, U = round_edge_weights_by_multiplying(t, U, 2, fixed_point_func=floor) # print(U) # for u, v in g_ceil.edges(): # if 'dummy' not in g_ceil.node[v]:
) parser.add_argument('--random_seed', type=int, default=None) args = parser.parse_args() random.seed(args.random_seed) np.random.seed(args.random_seed) dist_funcs = {'euclidean': euclidean, 'cosine': cosine} dist_func = dist_funcs[args.dist] lst = lambda g, r, U: lst_dag(g, r, U, edge_weight_decimal_point=args.fixed_point, debug=False) variance_method = lambda g, r, U: dp_dag_general( g, r, int(U*(10**args.fixed_point)), make_variance_cost_func(dist_func, 'topics', args.fixed_point), debug=False ) quota_based_method = lambda g, r, U: binary_search_using_charikar( g, r, U, args.charikar_level ) methods = {'lst': lst, 'lst+dij': lst,
trees = pkl.load(open('tmp/binary_rooted_tree_samples.pkl')) U = 0.5 names = [ # 'lst(round)', 'lst(ceil)', 'lst(floor)', # 'greedy' ] funcs = [ lambda g, r, U, func=func: lst_dag(g, r, U, fixed_point_func=func, debug=False, edge_weight_decimal_point=2) for func in ( # round, ceil, floor) ] # funcs.append(greedy_grow) # t = trees[5] # from lst import round_edge_weights_by_multiplying # g_ceil, U = round_edge_weights_by_multiplying(t, U, 2, fixed_point_func=ceil) # g_floor, U = round_edge_weights_by_multiplying(t, U, 2, fixed_point_func=floor) # print(U) # for u, v in g_ceil.edges():
parser.add_argument('--charikar_level', type=int, default=1, help="the `level` parameter in charikar's algorithm") parser.add_argument('--random_seed', type=int, default=None) args = parser.parse_args() random.seed(args.random_seed) np.random.seed(args.random_seed) dist_funcs = {'euclidean': euclidean, 'cosine': cosine} dist_func = dist_funcs[args.dist] lst = lambda g, r, U: lst_dag( g, r, U, edge_weight_decimal_point=args.fixed_point, debug=False) variance_method = lambda g, r, U: dp_dag_general( g, r, int(U * (10**args.fixed_point)), make_variance_cost_func(dist_func, 'topics', args.fixed_point), debug=False) quota_based_method = lambda g, r, U: binary_search_using_charikar( g, r, U, args.charikar_level) methods = { 'lst': lst, 'lst+dij': lst, 'variance': variance_method, 'greedy': greedy_grow_numpy,