def test_random_edges(self): """Test getting a graph by random edges.""" n_nodes, n_edges, n_sample_edges = 15, 80, 40 graph = generate_random_graph(n_nodes=n_nodes, n_edges=n_edges) subgraph = get_graph_with_random_edges(graph, n_edges=n_sample_edges) self.assertEqual(n_sample_edges, subgraph.number_of_edges())
def test_random_sample_small(self): """Test a graph that is too small to sample.""" n_nodes, n_edges = 11, 25 graph = generate_random_graph(n_nodes, n_edges) self.assertEqual(n_edges, graph.number_of_edges()) sg_1 = get_random_subgraph(graph, number_edges=250, number_seed_edges=5, invert_degrees=False) self.assertEqual( graph.number_of_edges(), sg_1.number_of_edges(), msg= 'since graph is too small, the subgraph should contain the whole thing' ) sg_2 = get_random_subgraph(graph, number_edges=250, number_seed_edges=5, invert_degrees=True) self.assertEqual( graph.number_of_edges(), sg_2.number_of_edges(), msg= 'since graph is too small, the subgraph should contain the whole thing' )
def test_random_sample(self): graph = generate_random_graph(50, 1000) seeding = Seeding() seeding.append_sample(number_edges=10) seeding.append_sample(number_edges=10) result = seeding.run(graph) # TODO this will fail randomly some times lol, so make allowed to be sort of wrong self.assertIn(result.number_of_edges(), {18, 19, 20})
def test_random_sample(self): """Test generating multiple random samples and combining them.""" graph = generate_random_graph(50, 1000) query = self.add_query(graph) query.append_seeding_sample(number_edges=10) query.append_seeding_sample(number_edges=10) result = self.run_query() self.assertIn(result.number_of_edges(), {16, 17, 18, 19, 20}, msg='This will rail randomly sometimes, lol')
def test_random_sample(self): """Test randomly sampling a graph.""" n_nodes, n_edges = 50, 500 graph = generate_random_graph(n_nodes=n_nodes, n_edges=n_edges) self.assertEqual(n_edges, graph.number_of_edges()) sg_1 = get_random_subgraph(graph, number_edges=250, number_seed_edges=5, invert_degrees=False) self.assertEqual(250, sg_1.number_of_edges()) sg_2 = get_random_subgraph(graph, number_edges=250, number_seed_edges=5, invert_degrees=True) self.assertEqual(250, sg_2.number_of_edges())