Example #1
0
 int get_highest_degree() {
     int n = mg->get_num_nodes();
     int max = 0;
     int i = 0;
     for(i = 0; i < n; i++) {
         if(max < mg->get_degree(i)) {
             max = mg->get_degree(i);
         }
     }
     return max;
 }
Example #2
0
 int get_lowest_degree() {
     int n = mg->get_num_nodes();
     int min = INT_MAX;
     int i = 0;
     for(i = 0; i < n; i++) {
         if(min > mg->get_degree(i)) {
             min = mg->get_degree(i);
         }
     }
     return min;
 }
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))
    ;
}