diff --git a/Makefile b/Makefile index 201f657..b623885 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: tmaze +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2019/03/27 16:51:02 by tmaze #+# #+# # -# Updated: 2019/04/10 14:24:30 by tmaze ### ########.fr # +# Updated: 2019/04/10 14:47:07 by tmaze ### ########.fr # # # #******************************************************************************# @@ -27,7 +27,7 @@ endif # Compilator CC = gcc -FLAGS = -Wall -Wextra -Werror +FLAGS = -Wall -Wextra -Werror -g # Folders LIBDIR = libft diff --git a/srcs/edmunds_karp.c b/srcs/edmunds_karp.c index 14a2f45..22d52e5 100644 --- a/srcs/edmunds_karp.c +++ b/srcs/edmunds_karp.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/28 16:21:19 by tmaze #+# #+# */ -/* Updated: 2019/04/08 18:49:53 by tmaze ### ########.fr */ +/* Updated: 2019/04/10 15:00:16 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -93,7 +93,6 @@ t_ind **edmunds_karp(t_lmdata *data, int start_ind, int end_ind) int nb_path; nb_path = 0; - ft_printf("data: %p\ndata->adj: %p\n\n", data, data->adj); if (data && data->adj) { bfs(data, tab, start_ind, end_ind); diff --git a/srcs/lem_in.c b/srcs/lem_in.c index 0f34663..15449e3 100644 --- a/srcs/lem_in.c +++ b/srcs/lem_in.c @@ -6,19 +6,27 @@ /* By: mndhlovu +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */ -/* Updated: 2019/04/10 14:26:07 by tmaze ### ########.fr */ +/* Updated: 2019/04/10 15:35:18 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "lem_in.h" -int lm_error_exit(void) +static t_node *get_node_role(t_lmdata *data, char role) { - ft_putendl_fd("ERROR", 2); - return (1); + t_node *it; + + it = data->nodes_data; + while (it) + { + if (it->role == role) + return (it); + it = it->next; + } + return (NULL); } -static int lem_in(t_syntax *synt, t_holder *holder, +static int lem_in(t_syntax *synt, t_holder *holder, t_lmdata *lmdata) { if (!(lm_parser(synt, lmdata, holder))) @@ -30,16 +38,19 @@ static int lem_in(t_syntax *synt, t_holder *holder, return (1); } -int main(int ac, char **av) +int lm_error_exit(void) { - t_syntax synt; - t_lmdata ldata; - t_holder holder; - t_ind **ret; - t_node *it; - t_node *start; - t_node *end; - int i; + ft_putendl_fd("ERROR", 2); + return (1); +} + +int main(int ac, char **av) +{ + t_syntax synt; + t_lmdata ldata; + t_holder holder; + t_ind **ret; + int i; (void)av; i = 0; @@ -48,19 +59,12 @@ int main(int ac, char **av) lm_init_data(&synt, &holder, &ldata); if (!(lem_in(&synt, &holder, &ldata))) return (lm_error_exit()); - it = ldata.nodes_data; - start = NULL; - end = NULL; - while (it && (!start || !end)) - { - if (it->role == 's') - start = it; - else if (it->role == 'e') - end = it; - it = it->next; - } - if ((!start) || (ret = edmunds_karp(&ldata, start->ind, end->ind)) == NULL) + if ((ret = edmunds_karp(&ldata, get_node_role(&ldata, 's')->ind + , get_node_role(&ldata, 'e')->ind)) == NULL) return (lm_error_exit()); + i = 0; + while (ret[i]) + i++; push_ants(&ldata, ret, i); tablst_inddel(ret); i = 0; diff --git a/srcs/push_ants.c b/srcs/push_ants.c index e9ffda6..2026e29 100644 --- a/srcs/push_ants.c +++ b/srcs/push_ants.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/06 11:37:56 by tmaze #+# #+# */ -/* Updated: 2019/04/10 14:15:59 by tmaze ### ########.fr */ +/* Updated: 2019/04/10 14:53:01 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,8 +58,8 @@ static void print_ants(t_lmdata *data, t_ants **ants, char *has_start ft_putchar('\n'); has_start[it->nb_path] = 0; it = it->next; - clean_ants(ants); } + clean_ants(ants); } void push_ants(t_lmdata *data, t_ind **paths, int nb_paths)