a bit more of normalising
normalising lem_in WIP
This commit is contained in:
parent
5d094ebcaf
commit
8c4a6aac25
4
Makefile
4
Makefile
@ -6,7 +6,7 @@
|
||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
|
@ -6,16 +6,24 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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,
|
||||
@ -30,15 +38,18 @@ static int lem_in(t_syntax *synt, t_holder *holder,
|
||||
return (1);
|
||||
}
|
||||
|
||||
int lm_error_exit(void)
|
||||
{
|
||||
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;
|
||||
t_node *it;
|
||||
t_node *start;
|
||||
t_node *end;
|
||||
int i;
|
||||
|
||||
(void)av;
|
||||
@ -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;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user