-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.h
100 lines (84 loc) · 2.28 KB
/
graph.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
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include <map>
#include <vector>
#include <string>
using namespace std;
class Graph {
public:
typedef string Node;
/**
* @brief Edge struct that contains a start and end Node
*
*/
struct Edge {
Node start_;
Node end_;
bool operator== (const Edge& other) const {
return start_ == other.start_ && end_ == other.end_;
}
};
/**
* @brief Construct a new Graph object
*
* @param filepath - The filepath containing node/edge data
*/
Graph(string filepath);
/**
* @brief Destroy the Graph object
*
*/
~Graph();
/**
* @brief Construct a new Graph object from another Graph
*
* @param g - The Graph to be copied
*/
Graph(const Graph &g);
/**
* @brief Assignment operator
*
* @param g - The Graph to be copied
* @return Graph&
*/
Graph& operator=(const Graph& g);
/**
* @brief Equality overloader
*
* @param other
* @return true
* @return false
*/
bool operator== (const Graph& other) const;
/**
* @brief Inequality overloader
*
* @param other
* @return true
* @return false
*/
bool operator!= (const Graph& other) const;
/**
* @brief Prints the graph in Node: Adjacent_Node Adjacent_Node ... format
*
* @param output
*/
void printGraph(std::ostream& output);
/**
* @brief Create a Adjacency List for the current Graph
*
* @param filepath
*/
void createAdjacencyList(string filepath);
/**
* @brief Get the Adjacency List
*
* @return map<Node, vector<Edge>>&
*/
map<Node, vector<Edge>> & getAdjacencyList();
private:
map<Node, vector<Edge>> adjacency_list_;
// Adds a Node to the Graph
void addNode(Node node);
// Adds an Edge to the Graph given a specific pair of Nodes
void addEdge(Node start, Node end);
};