Example #1
0
def test_random_edge_sampler():
    """
    Testing the edge retention rate.
    """
    sampler = RandomEdgeSampler()

    graph = nx.watts_strogatz_graph(200, 10, 0)

    new_graph = sampler.sample(graph)

    assert sampler.number_of_edges == new_graph.number_of_edges()
Example #2
0
def test_random_edge_sampler():
    """
    Testing the edge retention rate.
    """
    sampler = RandomEdgeSampler()

    graph = nx.watts_strogatz_graph(200, 10, 0)

    new_graph = sampler.sample(graph)

    assert sampler.number_of_edges == new_graph.number_of_edges()
    assert type(new_graph) == NXGraph

    sampler = RandomEdgeSampler(number_of_edges=25)

    graph = nx.watts_strogatz_graph(100, 10, 0)

    new_graph = sampler.sample(graph)

    assert sampler.number_of_edges == new_graph.number_of_edges()
    assert type(new_graph) == NXGraph

    sampler = RandomEdgeSampler()

    graph = nk.generators.WattsStrogatzGenerator(200, 10, 0.0).generate()

    new_graph = sampler.sample(graph)

    assert sampler.number_of_edges == new_graph.numberOfEdges()
    assert type(new_graph) == NKGraph

    sampler = RandomEdgeSampler(number_of_edges=25)

    graph = nk.generators.WattsStrogatzGenerator(100, 10, 0.0).generate()

    new_graph = sampler.sample(graph)

    assert sampler.number_of_edges == new_graph.numberOfEdges()
    assert type(new_graph) == NKGraph
Example #3
0
new_graph = sampler.sample(graph)

#-----------------------------
# Random Node Sampler Example
#-----------------------------

sampler = RandomNodeSampler()

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
#------------------------------
"""Random edge sampler example."""

import networkx as nx
from littleballoffur.edge_sampling import RandomEdgeSampler

graph = nx.watts_strogatz_graph(1000, 10, 0)

sampler = RandomEdgeSampler()

new_graph = sampler.sample(graph)