54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* lm_graph_utils.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
|
|
/* Updated: 2019/04/24 09:43:02 by tmaze ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "lem_in.h"
|
|
|
|
static int is_link_in(t_lmdata *data, int src, int dest)
|
|
{
|
|
t_ind *it;
|
|
if (src < data->nb_nodes)
|
|
{
|
|
it = data->adj[src];
|
|
while (it)
|
|
{
|
|
if (it->index == dest)
|
|
return (1);
|
|
it = it->next;
|
|
}
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
|
|
{
|
|
t_temp *data;
|
|
|
|
ft_printf("=== lm_adj_parser ===\nholder: %p\n\n", holder);
|
|
if (holder != NULL)
|
|
{
|
|
data = holder->data;
|
|
ft_printf("data: %p\n\n", data);
|
|
if (data != NULL)
|
|
{
|
|
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;
|
|
}
|
|
return (1);
|
|
}
|
|
}
|
|
return (0);
|
|
}
|