int perfect_path_get_path_with_callback_with_args(dBNode * node, Orientation orientation, void (*node_action) (dBNode * , void *), void * node_args, void (*path_action) (Path * , void *), void * path_args,dBGraph * db_graph) { WalkingFunctions wf; perfect_path_get_funtions(&wf); pathStep first; first.node = node; //first.orientation = orientation == undefined? reverse: orientation; first.orientation = orientation; first.label = Undefined; if (orientation != undefined) { db_node_has_precisely_one_edge_all_colours(node, orientation, &first.label); wf.get_starting_step = &get_first_step_identity; } //wf.find_first_node = &find_first; db_graph_add_node_action_with_args (&wf, node_action, node_args); db_graph_add_path_callback_with_args (&wf, path_action, path_args); Path *path = path_get_buffer_path(); int ret = db_graph_generic_walk(&first, path, &wf, db_graph); path_free_buffer_path(path); return ret; }
WalkingFunctions * branches_get_funtions(WalkingFunctions * walking_functions){ perfect_path_get_funtions(walking_functions); walking_functions->continue_backwards = &clean_path; walking_functions->get_next_step = &get_next_step; walking_functions->continue_traversing = &continue_traversing; walking_functions->get_starting_step = &get_first_step_label; return walking_functions; }
/*----------------------------------------------------------------------* * Function: * * Purpose: * * Params: * * Returns: * *----------------------------------------------------------------------*/ WalkingFunctions * coverage_walk_get_funtions(WalkingFunctions *walking_functions) { perfect_path_get_funtions(walking_functions); // Which to over-rule? walking_functions->continue_traversing = &coverage_walk_continue_traversing; walking_functions->get_next_step = &coverage_walk_get_next_step; walking_functions->pre_step_action = &coverage_walk_pre_step_action; walking_functions->post_step_action =&coverage_walk_post_step_action; return walking_functions; }
int perfect_path_get_path_from_step_with_callback_with_args(pathStep first, void (*node_action) (dBNode * node, void *),void * node_args, void (*path_action) (Path * path, void *), void * path_args, dBGraph * db_graph) { WalkingFunctions wf; perfect_path_get_funtions(&wf); wf.get_starting_step = &get_first_step_identity; db_graph_add_node_action_with_args (&wf, node_action, node_args); db_graph_add_path_callback_with_args (&wf, path_action, path_args); Path *path = path_get_buffer_path(); int ret = db_graph_generic_walk(&first, path, &wf, db_graph); path_free_buffer_path(path); return ret; }