cleaned up unused code normalised push_ants libft is no longer a submodule still need to normalise lem_in
77 lines
2.0 KiB
C
77 lines
2.0 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* lem_in.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
|
|
/* Updated: 2019/04/10 14:26:07 by tmaze ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "lem_in.h"
|
|
|
|
int lm_error_exit(void)
|
|
{
|
|
ft_putendl_fd("ERROR", 2);
|
|
return (1);
|
|
}
|
|
|
|
static int lem_in(t_syntax *synt, t_holder *holder,
|
|
t_lmdata *lmdata)
|
|
{
|
|
if (!(lm_parser(synt, lmdata, holder)))
|
|
return (0);
|
|
if (!lst_indinit(lmdata))
|
|
return (0);
|
|
if (!(lm_adj_parser(lmdata, holder)))
|
|
return (0);
|
|
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;
|
|
i = 0;
|
|
if (ac == 1)
|
|
{
|
|
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)
|
|
return (lm_error_exit());
|
|
push_ants(&ldata, ret, i);
|
|
tablst_inddel(ret);
|
|
i = 0;
|
|
while (i < ldata.nb_nodes)
|
|
{
|
|
lst_inddel(&(ldata.adj[i]));
|
|
i++;
|
|
}
|
|
ft_memdel((void**)&(ldata.adj));
|
|
return (0);
|
|
}
|
|
return (1);
|
|
}
|