-
Notifications
You must be signed in to change notification settings - Fork 0
/
labyrinth.h
53 lines (42 loc) · 1.03 KB
/
labyrinth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// Created by lenovo on 2022/10/31.
//
#ifndef BFS_LABYRINTH_H
#define BFS_LABYRINTH_H
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define max 1024
// initialize the node of labyrinth
typedef struct node
{
// the number of the node
int id;
// the node before searching this node
struct node* father;
}node;
// regard labyrinth as a graph
typedef struct Graph
{
// total number of nodes in the graph
int length;
// put the vex of labyrinth
node vexs[max];
// initialize the nearby matrix
int adjtype[max][max];
}Graph;
// create lists of OPEN, CLOSED in BFS
typedef struct List {
node* vex;
struct List* next;
}list;
list* createList();
int init(node *node, list*CLOSED);
list* hasNext(node* node, Graph* g, list* CLOSED);
Graph *CreateLabyrinth();
int isNearby(Graph *g, node*a, node*b);
node* pop(list *li);
int isEmpty(list* list);
void push(list* list, node* node);
int isTarget(node*Node, int target);
#endif //BFS_LABYRINTH_H