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(GraphCreatorFileTest, testGraph) { Graph::Graph *mg = creator->create_mutable_graph(); EXPECT_EQ(128, mg->get_num_nodes()) ; EXPECT_EQ(1471, mg->get_num_edges()) ; vector<Graph::Node> n; n = mg->get_nodes(); EXPECT_EQ(128, n.size()) ; list<int> nbrlist = n[35].get_nbrs(); vector<int> nbrs(nbrlist.begin(), nbrlist.end()); EXPECT_EQ(75, nbrs[20]) ; nbrlist = n[127].get_nbrs(); nbrs.clear(); nbrs.insert(nbrs.end(), nbrlist.begin(), nbrlist.end()); EXPECT_EQ(111, nbrs[2]) ; nbrlist = n[0].get_nbrs(); nbrs.clear(); nbrs.insert(nbrs.end(), nbrlist.begin(), nbrlist.end()); EXPECT_EQ(1, nbrs[0]) ; EXPECT_EQ(64, nbrs[6l]) ; EXPECT_EQ(8, nbrs[3l]) ; EXPECT_EQ(24, mg->get_degree(35)) ; EXPECT_EQ(28, mg->get_degree(75)) ; mg->remove_edge(35, 75); EXPECT_EQ(23, mg->get_degree(35)) ; EXPECT_EQ(27, mg->get_degree(75)) ; mg->remove_vertex(35); EXPECT_EQ(0, mg->get_degree(35)) ; EXPECT_EQ(27, mg->get_degree(75)) ; }