def test_induction_samplers(): """ Testing the density of induced subgraphs """ induced_sampler = RandomEdgeSamplerWithInduction() partially_induced_sampler = RandomEdgeSamplerWithPartialInduction() graph = nx.watts_strogatz_graph(200, 10, 0) induced_graph = induced_sampler.sample(graph) partially_induced_graph = partially_induced_sampler.sample(graph) assert nx.density(partially_induced_graph) <= nx.density(induced_graph)
def test_induction_samplers(): """ Testing the density of induced subgraphs """ induced_sampler = RandomEdgeSamplerWithInduction() partially_induced_sampler = RandomEdgeSamplerWithPartialInduction() graph = nx.watts_strogatz_graph(200, 10, 0) induced_graph = induced_sampler.sample(graph) partially_induced_graph = partially_induced_sampler.sample(graph) assert nx.density(partially_induced_graph) <= nx.density(induced_graph) assert type(induced_graph) == NXGraph assert type(partially_induced_graph) == NXGraph induced_sampler = RandomEdgeSamplerWithInduction() partially_induced_sampler = RandomEdgeSamplerWithPartialInduction() graph = nx.watts_strogatz_graph(100, 10, 0) induced_graph = induced_sampler.sample(graph) partially_induced_graph = partially_induced_sampler.sample(graph) assert nx.density(partially_induced_graph) <= nx.density(induced_graph) assert type(induced_graph) == NXGraph assert type(partially_induced_graph) == NXGraph induced_sampler = RandomEdgeSamplerWithInduction() partially_induced_sampler = RandomEdgeSamplerWithPartialInduction() graph = nk.generators.WattsStrogatzGenerator(200, 10, 0.0).generate() induced_graph = induced_sampler.sample(graph) partially_induced_graph = partially_induced_sampler.sample(graph) assert type(induced_graph) == NKGraph assert type(partially_induced_graph) == NKGraph induced_sampler = RandomEdgeSamplerWithInduction() partially_induced_sampler = RandomEdgeSamplerWithPartialInduction() graph = nk.generators.WattsStrogatzGenerator(100, 10, 0.0).generate() induced_graph = induced_sampler.sample(graph) partially_induced_graph = partially_induced_sampler.sample(graph) assert type(induced_graph) == NKGraph assert type(partially_induced_graph) == NKGraph
"""Random edge sampler with induction example.""" import networkx as nx from littleballoffur.edge_sampling import RandomEdgeSamplerWithInduction graph = nx.watts_strogatz_graph(1000, 10, 0) sampler = RandomEdgeSamplerWithInduction() new_graph = sampler.sample(graph)
new_graph = sampler.sample(graph) #----------------------------- # Random Edge Sampler Example #----------------------------- sampler = RandomEdgeSampler() new_graph = sampler.sample(graph) #-------------------------------------------- # Random Edge Sampler With Induction Example #-------------------------------------------- sampler = RandomEdgeSamplerWithInduction() new_graph = sampler.sample(graph) #------------------------------ # Degree Based Sampler Example #------------------------------ sampler = DegreeBasedSampler() new_graph = sampler.sample(graph) #-------------------------------- # PageRank Based Sampler Example #--------------------------------