fuckinlem_in/srcs/lm_graph_utils.c
Tanguy MAZE 54be2278c0 It finnaly kinda works
algorithm with no double nodes and nearly efficient enough
still some optimizations to find for --big-superposition maps
2019-04-18 20:18:50 +02:00

51 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lm_graph_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
/* Updated: 2019/04/11 20:34:58 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;
if (holder != NULL)
{
data = holder->data;
if (data != NULL)
{
while (data)
{
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);
}