-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdjList.h
88 lines (65 loc) · 2.06 KB
/
AdjList.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
#pragma once
#include <list>
#include <iostream>
#include <string>
#include <utility>
#include <cmath>
#include <queue>
#include <map>
class AdjList
{
private:
//internal structure of AdjList
//avoid compiler error
//main make up of AdjList
public:
struct VertexNode;
struct EdgeNode {
std::string ID;
double distance;
std::pair<VertexNode*, VertexNode*> ends;
};
struct VertexNode {
std::string ID;
double latitude;
double longitude;
std::list<EdgeNode*> edges;
std::list<EdgeNode*> asEnd;
};
std::list<VertexNode*> vertexList;
std::list<EdgeNode*> edgeList;
//ctors
AdjList();
AdjList(std::string vertexFile, std::string edgeFile);
//****Rule of 3***
//dtor
~AdjList();
//and assignment ctor
AdjList& operator =(const AdjList &other);
//copy ctor
AdjList(const AdjList& rhs);
//*******************
//Calculate distance between two nodes
double distance(VertexNode* start, VertexNode* end);
std::string getID(VertexNode* vertex);
void changeDistance(std::string name, double value);
void insertEdge(std::string name, VertexNode* start, VertexNode* end);
void insertVertex(std::string name, double lat , double longt);
//finding vertex/edge
VertexNode* findVertex(std::string name);
EdgeNode* findEdge(std::string name);
std::map<std::string, double> returnDistances();
//removing vertex/edge make sure to delete nodes from heap
void removeVertex(std::string name);
void removeEdge(std::string name);
//BFS traversal
void BFSTraversal();
void BFSTraversalID(std::string startVertex);
//Floyd-Warshall's Algorithm
//first is distrance, second is path
std::map<std::string, std::map<std::string, std::pair<double, VertexNode*>>> FWAlgorithm();
//Between-ness centrality
std::map<std::string, double> BCAlgorithm();
std::pair<std::string, double> FWSingleOutput(std::string start, std::string end);
double getShortestDistance(std::string start, std::string end);
};