Added scoring system to algorithm

still need testing and optimisations
not norm-compliant
This commit is contained in:
Tanguy MAZE
2019-04-13 14:56:39 +02:00
parent d85e0873cb
commit 9b75432c2e
6 changed files with 100 additions and 39 deletions

View File

@@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/27 14:41:49 by tmaze #+# #+# */
/* Updated: 2019/04/05 17:43:11 by tmaze ### ########.fr */
/* Updated: 2019/04/13 12:48:35 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,19 +37,21 @@ static void bfs_checkadj(t_lmdata *data, t_bfs *tab, int i)
{
if (tab[it->index].visited == 0 && it->weight == 2)
used = 1;
if (tab[it->index].visited == 0 && it->weight == 2)
if (used)
break ;
it = it->next;
}
it = data->adj[tab[i].queue];
while (it != NULL)
{
if (tab[it->index].visited == 0 && ((!used && it->weight > 0)
if (tab[it->index].visited == 0 && ((!used && it->weight == 1)
|| (used && it->weight == 2)))
bfs_addtoqueue(tab, it->index, data->nb_nodes);
if (tab[it->index].visited == 0 && ((!used && it->weight > 0)
if (tab[it->index].visited == 0 && ((!used && it->weight == 1)
|| (used && it->weight == 2)))
tab[it->index].parent = tab[i].queue;
if (it->weight == 2)
break ;
it = it->next;
}
}