current parser version ready for breaking..
This commit is contained in:
parent
9a386b315b
commit
6ad8cd2d95
14
map3
Normal file
14
map3
Normal file
@ -0,0 +1,14 @@
|
||||
21
|
||||
##start
|
||||
start 0 0
|
||||
##end
|
||||
end 1 1
|
||||
plop 2 2
|
||||
lol 4 4
|
||||
xd 3 3
|
||||
start-plop
|
||||
|
||||
end-plop
|
||||
start-lol
|
||||
xd-lol
|
||||
end-xd
|
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/18 09:59:11 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/21 16:11:56 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/26 12:49:36 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -109,11 +109,14 @@ t_ind **edmonds_karp(t_lmdata *data, int s_ind, int e_ind)
|
||||
scores[0] = 0;
|
||||
nb_paths = 0;
|
||||
i = 0;
|
||||
ft_printf("data: %p\ndata->nb_nodes: %d\ndata->adj: %p\n\n", data, data->nb_nodes, data->adj);
|
||||
while (i < data->nb_nodes)
|
||||
tab[i++].old_visited = 0;
|
||||
bfs(data, tab, s_ind, e_ind);
|
||||
ft_printf("tab[e_ind].parent: %d\n", tab[e_ind].parent);
|
||||
while (tab[e_ind].parent != -1)
|
||||
{
|
||||
ft_printf("new path\n");
|
||||
nb_paths++;
|
||||
update_weights(data, tab, s_ind, e_ind);
|
||||
ret[1] = resolve_paths(data, nb_paths, s_ind, e_ind);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/24 18:23:42 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/26 13:21:09 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -56,21 +56,22 @@ static void get_nb_paths_max(t_lmdata *data, int start, int end)
|
||||
static int lem_in(t_syntax *synt, t_holder *holder,
|
||||
t_lmdata *lmdata, t_ind ***ret)
|
||||
{
|
||||
if (!(lm_parser(synt, lmdata, holder)))
|
||||
return (0);
|
||||
lm_parser(synt, lmdata, holder);
|
||||
if (!(lm_verify_cmd(synt, holder, lmdata)))
|
||||
return (0);
|
||||
print_map(lmdata);
|
||||
if (!lst_indinit(lmdata))
|
||||
return (0);
|
||||
if (!(lm_adj_parser(lmdata, holder)))
|
||||
return (0);
|
||||
lm_adj_parser(lmdata, holder);
|
||||
lm_clear_unv(holder);
|
||||
get_nb_paths_max(lmdata, get_node_role(lmdata, 's')->ind
|
||||
, get_node_role(lmdata, 'e')->ind);
|
||||
if ((*ret = edmonds_karp(lmdata, get_node_role(lmdata, 's')->ind
|
||||
, get_node_role(lmdata, 'e')->ind)) == NULL)
|
||||
{
|
||||
ft_printf("plop\n");
|
||||
return (0);
|
||||
}
|
||||
if (!push_ants(lmdata, *ret, get_nb_paths(*ret)))
|
||||
return (0);
|
||||
tablst_inddel(*ret);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/22 08:55:30 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/26 11:50:56 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/26 13:35:05 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -64,11 +64,23 @@ void lm_clear_unv(t_holder *holder)
|
||||
holder->data = NULL;
|
||||
}
|
||||
|
||||
int lm_verify_links(t_holder *data, t_syntax *synt)
|
||||
{
|
||||
if (!synt->l_error || (synt->l_error && data->count > 0))
|
||||
{
|
||||
ft_printf("Bingo\n");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int lm_verify_cmd(t_syntax *synt, t_holder *holder, t_lmdata *data)
|
||||
{
|
||||
if (synt->s_cmd && synt->e_cmd && !synt->v_error
|
||||
&& !synt->l_error && !synt->e_error && !synt->s_error
|
||||
&& synt->nb_state && (holder->count > 0)
|
||||
if (synt->s_cmd && synt->e_cmd
|
||||
&& !synt->e_error && !synt->s_error
|
||||
&& !synt->v_error
|
||||
&& synt->nb_state
|
||||
&& lm_verify_links(holder, synt)
|
||||
&& (data->nb_nodes > 0))
|
||||
return (1);
|
||||
lm_clear_unv(holder);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/24 09:43:02 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/26 12:15:47 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -41,7 +41,6 @@ int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
|
||||
{
|
||||
while (data)
|
||||
{
|
||||
ft_printf("=== link ===\nis_lin_in: %d\n\n", is_link_in(lmdata, data->src_ind, data->dest_ind));
|
||||
if (!is_link_in(lmdata, data->src_ind, data->dest_ind))
|
||||
lst_indadd_link(lmdata, data->src_ind, data->dest_ind);
|
||||
data = data->next;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/25 06:31:37 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/26 09:33:50 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/26 12:15:05 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/20 15:24:51 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/26 11:58:52 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/26 13:05:45 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -78,8 +78,8 @@ int lm_parser(t_syntax *synt, t_lmdata *ldata,
|
||||
int index;
|
||||
|
||||
index = 0;
|
||||
while (ft_getline(&raw) > 0)
|
||||
{
|
||||
while (ft_getline(&raw) > 0 && raw[0] != '\0')
|
||||
{
|
||||
ft_printf("%s\n", raw);
|
||||
if (!(lm_get_ant_(index, ldata, synt, raw)) && index == 0)
|
||||
{
|
||||
@ -95,6 +95,7 @@ int lm_parser(t_syntax *synt, t_lmdata *ldata,
|
||||
ft_strdel(&raw);
|
||||
index++;
|
||||
}
|
||||
ft_printf("final raw: %s\n", raw);
|
||||
ft_strdel(&raw);
|
||||
ft_putchar('\n');
|
||||
return (1);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/04 09:24:45 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/26 11:51:12 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/26 13:35:09 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user