TEST_F(GraphTest, testIsEdge) { Graph::Node *n; n = g->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); EXPECT_TRUE(g->is_edge(108, 100)); n = g->get_node(80); list<int> nbrs2 = n->get_nbrs(); EXPECT_EQ(22, nbrs2.size()); EXPECT_FALSE(g->is_edge(80, 12)); }
TEST_F(VertexWeightedGraphTest, testGetNode) { Graph::Node *n; n = wmg->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); }
TEST_F(MutableGraphTest, testGetNode) { Graph::Node *n; n = mg->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); }
void remove_all_edges(int i){ list<int>::iterator it; Graph::Node *n = mg->get_node(i); list<int> nbrs = n->get_nbrs(); for(it = nbrs.begin(); it != nbrs.end(); ++it){ mg->remove_edge(i, *it); } }
TEST_F(VertexWeightedGraphTest, testIsEdge) { Graph::Node *n; n = wmg->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); EXPECT_TRUE(wmg->is_edge(108, 100)); }
TEST_F(MutableGraphTest, testIsEdge) { Graph::Node *n; n = mg->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); EXPECT_TRUE(mg->is_edge(108, 100)); }
TEST_F(MutableGraphTest, testEliminateVertex) { EXPECT_TRUE(mg->is_edge(108, 100)); EXPECT_EQ(1471, mg->get_num_edges()); EXPECT_EQ(24, mg->get_degree(108)); EXPECT_EQ(24, mg->get_degree(100)); Graph::Node *na; na = mg->get_node(108); list<int> nbrs_a = na->get_nbrs(); vector<int> nbrsvec_a(nbrs_a.begin(), nbrs_a.end()); Graph::Node *nb; nb = mg->get_node(100); list<int> nbrs_b = nb->get_nbrs(); vector<int> nbrsvec_b(nbrs_b.begin(), nbrs_b.end()); int common_nbrs = 0; int final_degree = 0; int new_edges = 0; for (int ia = 0; ia < nbrsvec_a.size(); ia++) { for (int ib = 0; ib < nbrsvec_b.size(); ib++) { if (nbrsvec_a[ia] == nbrsvec_b[ib]) { common_nbrs++; } } } new_edges = mg->get_degree(108) - common_nbrs - 1; new_edges = new_edges + mg->get_degree(100) - 1; mg->eliminate_vertex(108, NULL, true); EXPECT_FALSE(mg->is_edge(108, 100)); EXPECT_FALSE(mg->is_edge(100, 108)); EXPECT_EQ(1597, mg->get_num_edges()); EXPECT_EQ(new_edges, mg->get_degree(100)); EXPECT_EQ(0, mg->get_degree(108)); }
TEST_F(MutableGraphTest, testContractEdge) { EXPECT_TRUE(mg->is_edge(108, 100)); EXPECT_EQ(1471, mg->get_num_edges()); EXPECT_EQ(24, mg->get_degree(108)); EXPECT_EQ(24, mg->get_degree(100)); Graph::Node *na; na = mg->get_node(108); list<int> nbrs_a = na->get_nbrs(); vector<int> nbrsvec_a(nbrs_a.begin(), nbrs_a.end()); Graph::Node *nb; nb = mg->get_node(100); list<int> nbrs_b = nb->get_nbrs(); vector<int> nbrsvec_b(nbrs_b.begin(), nbrs_b.end()); int common_nbrs = 0; int final_degree = 0; int new_edges = 0; for (int ia = 0; ia < nbrsvec_a.size(); ia++) { for (int ib = 0; ib < nbrsvec_b.size(); ib++) { if (nbrsvec_a[ia] == nbrsvec_b[ib]) { common_nbrs++; } } } final_degree = mg->get_degree(108) + mg->get_degree(100) - common_nbrs - 2; new_edges = mg->get_num_edges() - common_nbrs - 1; int x = mg->contract_edge(108, 100); EXPECT_FALSE(mg->is_edge(108, 100)); EXPECT_FALSE(mg->is_edge(100, 108)); EXPECT_EQ(0, mg->get_degree(100)); EXPECT_EQ(new_edges, mg->get_num_edges()); EXPECT_EQ(final_degree, mg->get_degree(108)); }
TEST_F(GraphPropertyTest, testClique) { Graph::Node *n; n = mg->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); EXPECT_FALSE(properties.is_clique(mg, &nbrs)); nbrs.push_back(108); properties.make_clique(mg, &nbrs); EXPECT_TRUE(properties.is_clique(mg, &nbrs)); }
TEST_F(GraphUtilTest, testRecomputeDegree) { Graph::Node *n = mg->get_node(36); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(29, nbrs.size()); EXPECT_FALSE(mg->is_edge(36, 3)); mg->add_edge(36, 3); EXPECT_EQ(30, mg->get_degree(36)); mg->remove_edge(36, 3); nbrs.push_back(3); n->set_nbr(nbrs); nbrs = n->get_nbrs(); EXPECT_EQ(30, nbrs.size()); EXPECT_EQ(29, mg->get_degree(36)); util.recompute_degrees(mg); EXPECT_EQ(30, mg->get_degree(36)); }
TEST_F(GraphTest, testFuseVertices) { EXPECT_FALSE(g->is_edge(80, 12)); EXPECT_EQ(1471, g->get_num_edges()); EXPECT_EQ(22, g->get_degree(80)); EXPECT_EQ(19, g->get_degree(12)); Graph::Node *na; na = g->get_node(80); list<int> nbrs_a = na->get_nbrs(); vector<int> nbrsvec_a(nbrs_a.begin(), nbrs_a.end()); Graph::Node *nb; nb = g->get_node(12); list<int> nbrs_b = nb->get_nbrs(); vector<int> nbrsvec_b(nbrs_b.begin(), nbrs_b.end()); int common_nbrs = 0; int final_degree = 0; int new_edges = 0; for(int ia = 0; ia < nbrsvec_a.size(); ia++){ for(int ib = 0; ib < nbrsvec_b.size(); ib++){ if(nbrsvec_a[ia] == nbrsvec_b[ib]){ common_nbrs++; } } } final_degree = g->get_degree(80) + g->get_degree(12) - common_nbrs; new_edges = g->get_num_edges() - common_nbrs; int x = g->fuse_vertices(80, 12, false); EXPECT_FALSE(g->is_edge(80, 12)); EXPECT_FALSE(g->is_edge(12, 80)); EXPECT_EQ(0, g->get_degree(12)); EXPECT_EQ(new_edges, g->get_num_edges()); EXPECT_EQ(final_degree, g->get_degree(80)); }
TEST_F(MetisGraphReaderTest, testGetNode) { //dim_writer->write_graph(g); creator.set_file_name("data/1dc.128.met"); creator.set_graph_type("Metis"); g = creator.create_graph(); Graph::Node *n; n = g->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); }
TEST_F(GraphPropertyTest, testIsPath) { Graph::Node *n = mg->get_node(20); list<int> nbrs = n->get_nbrs(); EXPECT_GT(nbrs.size(), 0); EXPECT_TRUE(properties.is_path(mg, nbrs.front(), nbrs.back())); remove_all_edges(nbrs.front()); EXPECT_FALSE(properties.is_path(mg, nbrs.front(), nbrs.back())); EXPECT_GT(mg->get_num_edges(), 0); }
TEST_F(GraphReaderWriterFactoryTest, testDimacsGraphWriterGetNode) { gw = factory.create_writer("dimacs", "data/dimacsout.out"); gw->write_graph(g); creator.set_file_name("data/dimacsout.out"); creator.set_graph_type("dimacs"); g = creator.create_graph(); Graph::Node *n; n = g->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); }
TEST_F(DIMACSGraphWriterTest, testGetNode) { dim_writer->write_graph(g); creator.set_file_name("../data/1dc.128.out"); creator.set_graph_type("DIMACS"); g = creator.create_graph(); Graph::Node *n; n = g->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); }
TEST_F(MetisGraphWriterTest, testIsEdge) { dim_writer->write_graph(g); creator.set_file_name("../data/1dc.128.met"); creator.set_graph_type("Metis"); g = creator.create_graph(); Graph::Node *n; n = g->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); EXPECT_TRUE(g->is_edge(108, 100)); }
TEST_F(DIMACSGraphWriterTest, testshuffle) { string out_file("../data/1dc.128.out.shuf"); dim_writer->set_out_file_name(out_file); dim_writer->shuffle(g, time(NULL)); dim_writer->write_graph(g); creator.set_file_name("../data/1dc.128.out.shuf"); creator.set_graph_type("DIMACS"); g = creator.create_graph(); Graph::Node *n; n = g->get_node(108); list<int> nbrs = n->get_nbrs(); //BDS - problem if randomization happens to put a vertex of //degree 24 in this location. Temporary fix. //EXPECT_NE(24, nbrs.size()); EXPECT_NE(0, nbrs.size()); }
TEST_F(GraphPropertyTest, testIsIndependentSet) { Graph::Node *n = mg->get_node(20); list<int> nbrs = n->get_nbrs(); EXPECT_FALSE(properties.is_independent_set(mg, &nbrs)); list<int>::iterator it; list<int>::iterator jt; for(it = nbrs.begin(); it != nbrs.end(); ++it){ // Remove all edges between them for(jt = nbrs.begin(); jt != nbrs.end(); ++jt){ if(*it != *jt){ mg->remove_edge(*it, *jt); } } } EXPECT_TRUE(properties.is_independent_set(mg, &nbrs)); EXPECT_GT(mg->get_num_edges(), 0); }
TEST_F(GraphPropertyTest, testSimple) { Graph::Node *n; n = mg->get_node(108); list<int> nbrs = n->get_nbrs(); EXPECT_EQ(24, nbrs.size()); EXPECT_TRUE(mg->is_edge(108, 100)); EXPECT_EQ(24, mg->get_degree(108)); mg->add_edge(108, 100); mg->add_edge(108, 108); EXPECT_EQ(1473, mg->get_num_edges()); EXPECT_EQ(26, mg->get_degree(108)); EXPECT_FALSE(properties.check_simple(mg)); properties.make_simple(mg); EXPECT_TRUE(properties.check_simple(mg)); EXPECT_EQ(24, mg->get_degree(108)); }