@@ -946,57 +946,78 @@ void test_partition(int argc, char** argv) {
946946}
947947
948948
949- void test_topology_adjacent_list (int argc , char * * argv ) {
949+ void test_topology_structure (int argc , char * * argv ) {
950950 GRIN_GRAPH g = get_graph (argc , argv );
951951
952- GRIN_VERTEX v = get_one_vertex (g );
953-
954- GRIN_ADJACENT_LIST al = grin_get_adjacent_list (g , OUT , v );
955- GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin (g , al );
956- grin_destroy_adjacent_list (g , al );
957- size_t cnt = 0 ;
952+ printf ("vnum: %zu, enum: %zu\n" , grin_get_vertex_num (g ), grin_get_edge_num (g ));
958953
959- while (! grin_is_adjacent_list_end ( g , ali )) {
960- cnt ++ ;
954+ grin_destroy_graph ( g );
955+ }
961956
962- GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter (g , ali );
963- GRIN_VERTEX v1 = grin_get_src_vertex_from_edge (g , e );
964- if (!grin_equal_vertex (g , v , v1 )) {
965- printf ("vertex not match\n" );
966- }
957+ void test_topology_adjacent_list (int argc , char * * argv , GRIN_DIRECTION dir ) {
958+ GRIN_GRAPH g = get_graph (argc , argv );
967959
968- GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge (g , e );
969- GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter (g , ali );
970- if (!grin_equal_vertex (g , v2 , u )) {
971- printf ("vertex not match\n" );
972- }
960+ GRIN_VERTEX_LIST vl = grin_get_vertex_list (g );
961+ GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin (g , vl );
962+ grin_destroy_vertex_list (g , vl );
973963
974- grin_destroy_vertex (g , v1 );
975- grin_destroy_vertex (g , v2 );
976- grin_destroy_vertex (g , u );
977- grin_destroy_edge (g , e );
978- grin_get_next_adjacent_list_iter (g , ali );
979- }
964+ while (!grin_is_vertex_list_end (g , vli )) {
965+ GRIN_VERTEX v = grin_get_vertex_from_iter (g , vli );
966+ GRIN_ADJACENT_LIST al = grin_get_adjacent_list (g , dir , v );
967+ GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin (g , al );
968+ grin_destroy_adjacent_list (g , al );
980969
981- printf ("num of edge checked: %zu\n" , cnt );
970+ size_t cnt = 0 ;
971+ while (!grin_is_adjacent_list_end (g , ali )) {
972+ cnt ++ ;
973+ GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter (g , ali );
974+ GRIN_VERTEX v1 = grin_get_src_vertex_from_edge (g , e );
975+ GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge (g , e );
976+ GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter (g , ali );
982977
983- grin_destroy_adjacent_list_iter (g , ali );
984- grin_destroy_vertex (g , v );
985- grin_destroy_graph (g );
986- }
978+ if (dir == OUT ) {
979+ if (!grin_equal_vertex (g , v , v1 )) {
980+ printf ("vertex not match\n" );
981+ }
982+ if (!grin_equal_vertex (g , v2 , u )) {
983+ printf ("vertex not match\n" );
984+ }
985+ } else {
986+ if (!grin_equal_vertex (g , v , v2 )) {
987+ printf ("vertex not match\n" );
988+ }
989+ if (!grin_equal_vertex (g , v1 , u )) {
990+ printf ("vertex not match\n" );
991+ }
992+ }
987993
988- void test_topology_structure (int argc , char * * argv ) {
989- GRIN_GRAPH g = get_graph (argc , argv );
994+ grin_destroy_vertex (g , v1 );
995+ grin_destroy_vertex (g , v2 );
996+ grin_destroy_vertex (g , u );
997+ grin_destroy_edge (g , e );
998+ grin_get_next_adjacent_list_iter (g , ali );
999+ }
1000+ #ifdef GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_INT64
1001+ long long int vid = grin_get_vertex_original_id_of_int64 (g , v );
1002+ if (dir == OUT ) {
1003+ printf ("vertex %lld OUT adjacent list checked num: %zu\n" , vid , cnt );
1004+ } else {
1005+ printf ("vertex %lld IN adjacent list checked num: %zu\n" , vid , cnt );
1006+ }
1007+ #endif
9901008
991- printf ("vnum: %zu, enum: %zu\n" , grin_get_vertex_num (g ), grin_get_edge_num (g ));
1009+ grin_destroy_adjacent_list_iter (g , ali );
1010+ grin_destroy_vertex (g , v );
1011+ grin_get_next_vertex_list_iter (g , vli );
1012+ }
9921013
9931014 grin_destroy_graph (g );
9941015}
9951016
996-
9971017void test_topology (int argc , char * * argv ) {
9981018 test_topology_structure (argc , argv );
999- test_topology_adjacent_list (argc , argv );
1019+ test_topology_adjacent_list (argc , argv , OUT );
1020+ test_topology_adjacent_list (argc , argv , IN );
10001021}
10011022
10021023int main (int argc , char * * argv ) {
0 commit comments