-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataStructures.h
89 lines (58 loc) · 1.58 KB
/
DataStructures.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include<iostream>
#include<vector>
#include<list>
#include<stdlib.h>
#include<queue>
#include<limits>
#include "Graphics.h"
#define ww 0
#define bb 1
#define pp 2
using namespace std;
//use map
struct EdgeNode
{
EdgeNode* next = NULL;
struct VerticeNode* connectedto = NULL;
struct VerticeNode* belongsto = NULL;
int distance = -1;
int color = 0;
};
struct VerticeNode
{
int data;
list<EdgeNode> linkedlist;
// EdgeNode* head=NULL;
int currentdistance = -1;
int hasbeenvisited = 0;
SDL_Rect circrect;
int flag = 0;
};
class greaternode
{
public:
bool operator()(VerticeNode A, VerticeNode B)
{
return A.currentdistance > B.currentdistance;
}
};
class Graph
{
public:
vector<VerticeNode> NodeArray; // used for holding all the vertices
list<VerticeNode>UnvisitedNodes; // used for holding unvisited nodes;
vector<EdgeNode>ENodeArray; //used for holding distances with the vertice nodes they are connected to
priority_queue<VerticeNode, vector<VerticeNode>, greaternode> NodeQueue;
static int successes; // used for finding the number of times it has found a path
Graph();
void setup();
void AddEdge(VerticeNode &A, VerticeNode &B, int dist);
void AddVertice(int x, int y);
void ConnectedTo();
void shortestpath(VerticeNode &A, VerticeNode &B);
void alternateshortestpath(VerticeNode &A, VerticeNode &B);
void calcdist(EdgeNode anedgenode, int orgcurrentdist);
void startshorestpath(VerticeNode &A, VerticeNode &B);
void cleanup();
};