@@ -11171,6 +11171,84 @@ SEXP R_igraph_find_cycle(SEXP graph, SEXP mode) {
1117111171 return (r_result );
1117211172}
1117311173
11174+ /*-------------------------------------------/
11175+ / igraph_simple_cycles /
11176+ /-------------------------------------------*/
11177+ SEXP R_igraph_simple_cycles (SEXP graph , SEXP mode , SEXP max_cycle_length ) {
11178+ /* Declarations */
11179+ igraph_t c_graph ;
11180+ igraph_vector_int_list_t c_vertices ;
11181+ igraph_vector_int_list_t c_edges ;
11182+ igraph_neimode_t c_mode ;
11183+ igraph_integer_t c_max_cycle_length ;
11184+ SEXP vertices ;
11185+ SEXP edges ;
11186+
11187+ SEXP r_result , r_names ;
11188+ /* Convert input */
11189+ R_SEXP_to_igraph (graph , & c_graph );
11190+ if (0 != igraph_vector_int_list_init (& c_vertices , 0 )) {
11191+ igraph_error ("" , __FILE__ , __LINE__ , IGRAPH_ENOMEM );
11192+ }
11193+ IGRAPH_FINALLY (igraph_vector_int_list_destroy , & c_vertices );
11194+ if (0 != igraph_vector_int_list_init (& c_edges , 0 )) {
11195+ igraph_error ("" , __FILE__ , __LINE__ , IGRAPH_ENOMEM );
11196+ }
11197+ IGRAPH_FINALLY (igraph_vector_int_list_destroy , & c_edges );
11198+ c_mode = (igraph_neimode_t ) Rf_asInteger (mode );
11199+ IGRAPH_R_CHECK_INT (max_cycle_length );
11200+ c_max_cycle_length = (igraph_integer_t ) REAL (max_cycle_length )[0 ];
11201+ /* Call igraph */
11202+ IGRAPH_R_CHECK (igraph_simple_cycles (& c_graph , & c_vertices , & c_edges , c_mode , c_max_cycle_length ));
11203+
11204+ /* Convert output */
11205+ PROTECT (r_result = NEW_LIST (2 ));
11206+ PROTECT (r_names = NEW_CHARACTER (2 ));
11207+ PROTECT (vertices = R_igraph_vector_int_list_to_SEXPp1 (& c_vertices ));
11208+ igraph_vector_int_list_destroy (& c_vertices );
11209+ IGRAPH_FINALLY_CLEAN (1 );
11210+ PROTECT (edges = R_igraph_vector_int_list_to_SEXPp1 (& c_edges ));
11211+ igraph_vector_int_list_destroy (& c_edges );
11212+ IGRAPH_FINALLY_CLEAN (1 );
11213+ SET_VECTOR_ELT (r_result , 0 , vertices );
11214+ SET_VECTOR_ELT (r_result , 1 , edges );
11215+ SET_STRING_ELT (r_names , 0 , Rf_mkChar ("vertices" ));
11216+ SET_STRING_ELT (r_names , 1 , Rf_mkChar ("edges" ));
11217+ SET_NAMES (r_result , r_names );
11218+ UNPROTECT (3 );
11219+
11220+ UNPROTECT (1 );
11221+ return (r_result );
11222+ }
11223+
11224+ /*-------------------------------------------/
11225+ / igraph_simple_cycles_callback /
11226+ /-------------------------------------------*/
11227+ SEXP R_igraph_simple_cycles_callback (SEXP graph , SEXP mode , SEXP max_cycle_length , SEXP cycle_handler ) {
11228+ /* Declarations */
11229+ igraph_t c_graph ;
11230+ igraph_neimode_t c_mode ;
11231+ igraph_integer_t c_max_cycle_length ;
11232+ igraph_cycle_handler_t c_cycle_handler ;
11233+
11234+ igraph_error_t c_result ;
11235+ SEXP r_result ;
11236+ /* Convert input */
11237+ R_SEXP_to_igraph (graph , & c_graph );
11238+ c_mode = (igraph_neimode_t ) Rf_asInteger (mode );
11239+ IGRAPH_R_CHECK_INT (max_cycle_length );
11240+ c_max_cycle_length = (igraph_integer_t ) REAL (max_cycle_length )[0 ];
11241+ /* Call igraph */
11242+ IGRAPH_R_CHECK (igraph_simple_cycles_callback (& c_graph , c_mode , c_max_cycle_length , c_cycle_handler , 0 ));
11243+
11244+ /* Convert output */
11245+
11246+
11247+
11248+ UNPROTECT (1 );
11249+ return (r_result );
11250+ }
11251+
1117411252/*-------------------------------------------/
1117511253/ igraph_is_eulerian /
1117611254/-------------------------------------------*/
0 commit comments