done all mechanism to display ants moving in the graph still need testing still need norming
143 lines
3.3 KiB
C
143 lines
3.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* lem_in.h :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/03/23 17:31:19 by tmaze #+# #+# */
|
|
/* Updated: 2019/04/06 13:49:17 by tmaze ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef LEM_IN_H
|
|
# define LEM_IN_H
|
|
|
|
# include "libft.h"
|
|
# include "limits.h"
|
|
# include <fcntl.h>
|
|
|
|
typedef struct s_node
|
|
{
|
|
char *name;
|
|
int x;
|
|
int y;
|
|
char role;
|
|
int ind;
|
|
struct s_node *next;
|
|
} t_node;
|
|
|
|
typedef struct s_ind
|
|
{
|
|
int index;
|
|
int weight;
|
|
struct s_ind *next;
|
|
} t_ind;
|
|
|
|
typedef struct s_lmdata
|
|
{
|
|
int nbants;
|
|
int nb_nodes;
|
|
t_list *nodes;
|
|
t_node *nodes_data;
|
|
t_ind **adj;
|
|
} t_lmdata;
|
|
|
|
typedef struct s_bfs
|
|
{
|
|
int parent;
|
|
char visited;
|
|
int queue;
|
|
} t_bfs;
|
|
|
|
typedef struct s_ants
|
|
{
|
|
int nb_ant;
|
|
int nb_path;
|
|
int nb_node;
|
|
char end;
|
|
struct s_ants *next;
|
|
} t_ants;
|
|
|
|
//LEM_IN MT STRUCTS
|
|
|
|
typedef struct s_syntax
|
|
{
|
|
int nb_state;
|
|
int s_cmd;
|
|
int s_pos;
|
|
int error;
|
|
int s_vert;
|
|
int e_vert;
|
|
int gr_status;
|
|
int e_cmd;
|
|
int e_pos;
|
|
int v_flag;
|
|
} t_syntax;
|
|
|
|
typedef struct s_AdjListNode
|
|
{
|
|
int dest;
|
|
struct s_AdjListNode *next;
|
|
} t_adjlist;
|
|
|
|
typedef struct s_temp
|
|
{
|
|
int src_ind;
|
|
int dest_ind;
|
|
struct s_temp *next;
|
|
} t_temp;
|
|
|
|
typedef struct s_holder
|
|
{
|
|
int count;
|
|
t_temp *data;
|
|
} t_holder;
|
|
|
|
typedef struct s_AdjList
|
|
{
|
|
t_adjlist *head;
|
|
} t_adj;
|
|
|
|
typedef struct s_graph
|
|
{
|
|
int v;
|
|
t_adj *array;
|
|
} t_graph;
|
|
|
|
typedef struct s_neighbour
|
|
{
|
|
int vertnum;
|
|
struct s_neighbor *next;
|
|
} t_neighbor;
|
|
|
|
//MT-FUNCTIONS
|
|
int lm_error_exit(int flag);
|
|
int lm_validate(t_syntax *synt, t_lmdata *lmdata);
|
|
void lm_parser(int fd, t_syntax *synt, t_lmdata *ldata,
|
|
t_holder *holder);
|
|
int lm_check_room_before(char **tab, t_syntax *synt);
|
|
void lm_init_data(t_syntax *synt, t_lmdata *ldata, t_holder *holder);
|
|
int lm_add_vertex(t_lmdata *ldata, char *raw, char flag, t_syntax *synt);
|
|
t_adjlist *lm_new_node(int dest);
|
|
t_graph *lm_creategraph(int v);
|
|
void lm_add_edge(t_graph *graph, int src, int dest);
|
|
int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw);
|
|
int lm_find_index(t_lmdata *data, char *str);
|
|
|
|
|
|
|
|
void lm_initdata(t_lmdata *data);
|
|
int lm_getparams(t_lmdata *data);
|
|
|
|
|
|
|
|
t_ind *lst_indadd(t_ind **lst, int ind);
|
|
void lst_inddel(t_ind **lst);
|
|
void tablst_inddel(t_ind **tab);
|
|
|
|
void bfs(t_lmdata *data, t_bfs *tab, int start_ind, int end_ind);
|
|
t_ind **edmunds_karp(t_lmdata *data, int start_ind, int end_ind);
|
|
|
|
#endif
|