<jupyter_start><jupyter_text>Edge sampling<jupyter_code>edge_sampling=False
if edge_sampling:
    sampling_rates=[0.1, 0.3, 0.5, 0.7, 0.9]
    sampler = ParametersZip(EdgeSampler(), {'desired_fraction' : sampling_rates})
    result1=GraphPipeline(graphs, measures, sampler=sampler).execute(repetitions=5)
if edge_sampling:
    display(Markdown("# edge sampling"))
    plot(result1)<jupyter_output><empty_output><jupyter_text>Node Sampling<jupyter_code>node_sampling=False
if node_sampling:
    sampler = ParametersZip(NodeSampler(), {'desired_fraction' : sampling_rates})

    result2=GraphPipeline(graphs, measures, sampler=sampler).execute(repetitions=5)
if node_sampling:
    display(Markdown("# node_sampling"))
    plot(result2)<jupyter_output><empty_output><jupyter_text>snowball sampling<jupyter_code>#def start_func(graph):
#    return np.random.choice(graph.get_vertices(), int(graph.num_vertices()*0.01), replace=False)
#sampler = ParametersZip(SnowballSampler(start_func), {'desired_fraction' : sampling_rates,
#                                           'retain_factor' : 1})
#result3=GraphPipeline(graphs, measures, sampler=sampler).execute(repetitions=5)
#display(Markdown("# snowball sampling"))
#plot(result3)<jupyter_output><empty_output><jupyter_text>Similarity sampling: Keep top edges by similarity<jupyter_code>sampler = ParametersZip(SimilarityEdgeSampler2(), {'sim_type':'jaccard', 'retain_factor' : [0.1,0.3,0.5,0.7,0.9,1]})
result4 = GraphPipeline(graphs, measures, sampler=sampler).execute(repetitions=1)
display(Markdown("# similarity sampling"))
plot(result4, maxk=1000, show_std=False)#[np.logical_and(result4.retain_factor != 0.5, result4.retain_factor != 0.3 )])
def plot2(result, measure="degree", cmap=None, **kwargs):
    plt.set_cmap("Reds")
    for name in np.unique(result.name):
        display(Markdown(f"# {name}"))
        result_tmp = result[result.name ==name]
        for measure in ["degree"]:#, "pagerank", "katz"]:#, "katz", "betweenness"]:
            display(Markdown(f"### {measure}"))
            fig = plot_top_places(result_tmp, measure=measure,  groupby="alpha", cmap=cmap, **kwargs)
            display(fig)

    
def to_alpha(alpha, values):
    return values ** alpha
samp = AdditionalParamWrapper(SimilarityEdgeSampler(), partial(change_function_params, to_alpha), "alpha")
#samp.function
sampler_2 = ParametersZip(samp, {'sim_type':'jaccard', 'alpha' : [0, 0.01, 0.1, 0.5, 1.0, 2.0]})
result5 = GraphPipeline(graphs, measures, sampler=sampler_2).execute(repetitions=10)
plot2(result5, maxk=1000, show_std=False, cmap=my_cmap)
raise NotImplementedError
def plot3(result, measure="degree", cmap=None, **kwargs):
    plt.set_cmap("Reds")
    for name in np.unique(result.name):
        display(Markdown(f"# {name}"))
        result_tmp = result[result.name ==name]
        for measure in ["degree"]:#, "pagerank", "katz"]:#, "katz", "betweenness"]:
            display(Markdown(f"### {measure}"))
            fig = plot_distr(result_tmp, groupby="retain_factor", cmap=cmap, **kwargs)
            display(fig)

plot_distr_outer(result4, normalize=False, show_std=False)<jupyter_output><empty_output>