Пример #1
0
def rwrw_size_estimate(graph, n_samples=-1, walk_length=200, thinning=40):
    # determine the number of samples
    if n_samples == -1: n_samples = graph.size() * 2
    samples = RWRW(graph, n_samples, length=walk_length, thinning=thinning)
    node_degrees = [graph.degree(node) for node in samples]
    sum_of_degrees = sum(node_degrees)
    sum_of_inverse_degrees = sum(graphsize.inverse_seq(node_degrees))
    collisions = graphsize.collision_count(samples)
    return graphsize.estimate_size(sum_of_degrees, sum_of_inverse_degrees, collisions)
Пример #2
0
def uis_wr_size_estimate(graph, n_samples=-1):
    # determine the number of samples
    if n_samples == -1: n_samples = graph.size() * 2

    #uniform sample so degree ratios fixed to 1
    sum_of_degrees = n_samples
    sum_of_inverse_degrees = n_samples
    node_samples = UIS_WR(graph.nodes(), n_samples)
    collisions = graphsize.collision_count(node_samples)
    return graphsize.estimate_size(sum_of_degrees, sum_of_inverse_degrees, collisions)
Пример #3
0
def wis_wr_size_estimate(graph, n_samples=-1):
    # determine the number of samples
    if n_samples == -1:
        n_samples = graph.size() * 2
    samples = graphsize.WIS_WR(graphsize.degree_weighted_nodes_for(graph), n_samples)
    node_degrees = [graph.degree(node) for node in samples]
    sum_of_degrees = sum(node_degrees)
    sum_of_inverse_degrees = sum(graphsize.inverse_seq(node_degrees))
    collisions = graphsize.collision_count(samples)
    return graphsize.estimate_size(sum_of_degrees, sum_of_inverse_degrees, collisions)
Пример #4
0
def estimate_size_with_mhrw(graph, n_samples=-1, thinning=1, random_walk_length=20):
    # determine the number of samples
    if n_samples == -1: n_samples = graph.size() * 4

    #sample the graph and process the results
    node_samples = MHRW(graph, graph.nodes(), n_samples, length=random_walk_length, thinning=thinning)
    degrees = [graph.degree(node) for node in node_samples]
    sum_of_degrees = sum(degrees)
    sum_of_inverse_degrees = sum(graphsize.inverse_seq(degrees))

    collisions = graphsize.collision_count(node_samples)

    print 'Sum of degrees: ', sum_of_degrees
    print 'Sum of inverse degrees: ', sum_of_inverse_degrees
    print 'Repeated samples: ', collisions

    return graphsize.estimate_size(sum_of_degrees, sum_of_inverse_degrees, collisions)
Пример #5
0
 def test_collision_count_counts_collisions(self):
     """collision_count should sum the number of all unique like-value set pairs (collisions) found"""
     self.assertEqual(1, graphsize.collision_count([1, 1]))
     self.assertEqual(1, graphsize.collision_count([1, 2, 1]))
     self.assertEqual(1 + 1, graphsize.collision_count([2, 1, 1, 2]))
     self.assertEqual(1 + 3, graphsize.collision_count([4, 6, 4, 6, 6]))